搜尋套件、儲存庫與 APP 分類

sticky_headers 封面
套件詳情v0.3.0+2

sticky_headers

Flutter 粘性標題 - 讓您在可滾動內容上放置標題,當內容滾動時,標題將黏附在容器頂部。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
1.8萬
喜歡數
903
Pub 分數
140

安裝套件

flutter pub add sticky_headers

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

StickyHeaders 是一個 Flutter 套件,可讓標題在使用者滾動內容時保持固定於可滾動清單的頂部。它非常適合建立分組清單,例如聯絡人或日曆項目,其中節區標題應在滾動過程中保持可見。該套件與 ListView 及其他可滾動組件無縫整合,提供流暢的效能和可自訂的標題行為。它支援所有主要平台,包括 Android、iOS、Web、macOS、Windows 和 Linux。

適用情境

  • 分組列表
  • 聯絡人清單
  • 日曆檢視
  • 分段數據展示
  • 可捲動內容與固定標題

主要特色

  • 滾動時的黏性標題
  • 可自訂的標題樣式
  • 平滑滾動整合
  • 支援多個可滾動的組件
  • 跨平台相容性

適合對象

  • 開發基於清單應用程式的開發者
  • 包含分類資料的應用程式
  • 需要持久化部分標題的 UI
  • Flutter 初學者學習可滾動版面
  • 針對多個平台的專案

使用建議

  • 在大型資料集上可能會影響效能
  • 需要仔細處理標題高度
  • 有限的內建動畫
  • 未針對高度動態內容進行優化
  • 在複雜佈局中,可能需要手動調整標題位置

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

Flutter Community: sticky_headers

Flutter Sticky Headers

pub package

Lets you place headers on scrollable content that will stick to the top of the container whilst the content is scrolled.

Usage

You can place a StickyHeader or StickyHeaderBuilder inside any scrollable content, such as: ListView, GridView, CustomScrollView, SingleChildScrollView or similar.

Depend on it:

dependencies:
  sticky_headers: "^0.3.0"

Import it:

import 'package:sticky_headers/sticky_headers.dart';

Use it:

class Example extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return ListView.builder(itemBuilder: (context, index) {
      return StickyHeader(
        header: Container(
          height: 50.0,
          color: Colors.blueGrey[700],
          padding: EdgeInsets.symmetric(horizontal: 16.0),
          alignment: Alignment.centerLeft,
          child: Text('Header #$index',
            style: const TextStyle(color: Colors.white),
          ),
        ),
        content: Container(
          child: Image.network(
            imageForIndex(index), 
            fit: BoxFit.cover,
            width: double.infinity, 
            height: 200.0,
          ),
        ),
      );
    });
  }
}

Examples

Example 1 - Headers and Content

Demo 1

Example 2 - Animated Headers with Content

Demo 2

Example 3 - Headers overlapping the Content

Demo 3

Bugs/Requests

If you encounter any problems feel free to open an issue. If you feel the library is missing a feature, please raise a ticket on Github and I'll look into it. Pull request are also welcome.

所屬分類

原始碼儲存庫

使用此套件的專案