搜索插件、代码仓与 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.

所属分类

源码仓库

使用此插件的项目