搜索插件、代码仓与 APP 分类

sliver_app_bar_builder 封面
插件详情v1.1.1

sliver_app_bar_builder

一个真正可自定义的滑动条,适用于应用栏,并且可以使用构建器来实现。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
1.6万
喜欢数
121
Pub 分数
160

安装插件

flutter pub add sliver_app_bar_builder

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

一个高度可定制的滑动条应用栏,利用构建器模式动态生成内容。它使开发者能够以细粒度控制布局和行为,构建复杂且响应式的应用栏。专为在可滚动列表中使用而设计,支持平滑过渡,并与 Flutter 的滑动条系统无缝集成。该包非常适合创建沉浸式滚动体验,其中标题会根据滚动位置或状态变化进行自适应。

适合场景

  • 可自定义的滚动列表中的应用栏
  • 基于滚动位置的动态页眉内容
  • 复杂的UI布局与滑块
  • 适用于移动设备和网页的响应式设计
  • 在应用栏中实现视差效果
  • 构建交互式导航标题

主要特点

  • 基于构建器的内容创作
  • 对银色行为的完全自定义
  • 支持所有主要平台
  • 与 ScrollViews 的平滑集成
  • 可适应滚动进度
  • 可扩展以支持高级 UI 模式

适合对象

  • 开发复杂可滚动界面的开发者
  • 需要灵活标题组件的设计人员
  • 需要动态应用栏行为的应用
  • 跨平台应用,针对多种设备
  • 使用声明式 UI 模式的团队

使用建议

  • 需要理解 Flutter 的 Sliver 系统
  • 可能会增加简单应用栏的复杂性
  • 最适合高级UI需求
  • 不建议用于基本静态标题
  • 性能取决于构建器逻辑的效率

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

netglade

Developed with 💚 by netglade

ci pub package license: MIT style: netglade analysis Discord


A truly customizable sliver for app bars with the benefit of using builders. Check the storybook demo and play with it yourself.

SliverAppBarBuilder supports various configurations:

  • bar
    • height
    • initialHeight (when expanded)
    • background (for everything or bar only)
  • content
    • builder
    • initialHeight
    • toggle contentBelowBar (whether content is on top or below bar)
    • padding
  • leading and trailing actions
    • list of builders
    • toggle collapsing
    • padding
  • stretching
    • toggle stretch
    • stretchConfiguration
  • misc
    • pinned mode
    • toggle mode
    • toggle debug (so you can debug each part visually)

Getting Started

Using the package is simple. Just use the sliver SliverAppBarBuilder in place of SliverAppBar, configure all the properties, and enjoy.

Each builder, for content or leading/trailing actions, provides expand ratio and content/bar height, so you can easily use these values to customize your headers.

  • expandRatio is a value between 1.0 when expanded and 0.0 when shrunken
  • contentHeight/barHeight are current heights of corresponding parts

Content builder has additional property:

  • centerPadding, when contentBelowBar is false, is a value used to offset content to center it with bar

An example of a header with title moving from under back button to its right might look like this:

CustomScrollView(
  slivers: [
    SliverAppBarBuilder(
      barHeight: 60,
      pinned: true,
      leadingActions: [
        (context, expandRatio, barHeight, overlapsContent) {
          return SizedBox(
            height: barHeight,
            child: const BackButton(),
          );
        }
      ],
      initialContentHeight: 150,
      contentBuilder: (context, expandRatio, contentHeight, centerPadding, overlapsContent) {
        return Container(
          alignment: Alignment.centerLeft,
          height: 60,
          transform: Matrix4.translationValues(10 + (1 - expandRatio) * 40, 0, 0),
          child: Text(
            'My Title',
            style: TextStyle(
              fontSize: 22 + expandRatio * 10,
              color: Colors.white,
              fontWeight: FontWeight.bold,
            ),
          ),
        );
      },
    ),
  ],
);

Development

Flutter is pinned with FVM in .fvmrc (currently 3.41.5):

fvm install
fvm flutter pub get

The repository uses Melos as a task runner (the published package lives in the repository root, so the root itself is the only Melos package). Melos is configured with sdkPath: .fvm/flutter_sdk, so scripts always run against the pinned SDK:

fvm dart run melos run lint:all      # format check + flutter analyze + DCM
fvm dart run melos run lint:format   # dart format --set-exit-if-changed
fvm dart run melos run lint:dart     # flutter analyze
fvm dart run melos run lint:dcm      # dcm analyze
fvm dart run melos run format        # write formatting
fvm dart run melos run test          # flutter test

Run fvm dart run melos run --list to see all scripts. CI runs the very same commands; where FVM is not available, set MELOS_SDK_PATH=auto to run the scripts against the SDK on the PATH.

lint:dcm needs the DCM CLI on the PATH; the version used by CI is pinned in dcm_global.yaml.

所属分类

源码仓库

使用此插件的项目

暂无相关数据。