パッケージ、リポジトリ、アプリカテゴリを検索

flutter_sticky_header のカバー
パッケージ詳細v0.8.0

flutter_sticky_header

Flutterによるスタティックヘッダーのスリーブとしての実装。CustomScrollViewで使用します。

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
30.6万
いいね数
943
Pub ポイント
150

パッケージをインストール

flutter pub add flutter_sticky_header

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

スライバーを使用して CustomScrollView 内でスタックヘッダーを実装する Flutter パッケージです。ユーザーがリストやグリッドをスクロールする際に、ヘッダーがスクロールコンテンツの上部に常に表示されるようにし、ナビゲーションと視覚的な整理を向上させます。連絡先、メッセージ、カテゴリ分けされたデータなど、グループ化された項目を持つ長いリストに最適です。パッケージは軽量で、ドキュメントが充実しており、すべての主要プラットフォームで互換性があります。

用途

  • グループ化されたリストビュー
  • アルファベットヘッダー付きの連絡先リスト
  • 日付ヘッダー付きのメッセージスレッド
  • カテゴリ化された製品リスト
  • セクションヘッダー付きのスクロール可能なダッシュボード

主な機能

  • Sliver をベースとした実装
  • 自動ヘッダーのピン留め
  • カスタマイズ可能なヘッダーのスタイル
  • スムーズなスクロール動作
  • クロスプラットフォーム対応
  • CustomScrollView との簡単な統合

適している対象

  • セクション付きのスクロール可能なリストを構築している開発者
  • 視覚的に整理されたコンテンツを必要とするアプリ
  • パフォーマンス最適化ヘッダーを必要とするプロジェクト
  • プラットフォームの整合性を最優先とするチーム

注意事項

  • CustomScrollView 内での使用を必要とします
  • 複雑なヘッダーには追加のレイアウト調整が必要になる場合があります
  • スリバー以外のスクロールコンテキストには適していません
  • 基本的なスタイリングを超えるカスタマイズが限られている
  • 非常に大きなデータセットでのパフォーマンスへの影響

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

flutter_sticky_header

A Flutter implementation of sticky headers with a sliver as a child.

Pub Donate

Screenshot

Features

  • Accepts one sliver as content.
  • Header can overlap its sliver (useful for sticky side header for example).
  • Notifies when the header scrolls outside the viewport.
  • Can scroll in any direction.
  • Supports overlapping (AppBars for example).
  • Supports not sticky headers (with sticky: false parameter).
  • Supports a controller which notifies the scroll offset of the current sticky header.

Getting started

In the pubspec.yaml of your flutter project, add the following dependency:

dependencies:
  ...
  flutter_sticky_header:

In your library add the following import:

import 'package:flutter_sticky_header/flutter_sticky_header.dart';

For help getting started with Flutter, view the online documentation.

SliverStickyHeader

You can place one or multiple SliverStickyHeaders inside a CustomScrollView.

SliverStickyHeader(
  header: Container(
    height: 60.0,
    color: Colors.lightBlue,
    padding: EdgeInsets.symmetric(horizontal: 16.0),
    alignment: Alignment.centerLeft,
    child: Text(
      'Header #0',
      style: const TextStyle(color: Colors.white),
    ),
  ),
  sliver: SliverList(
    delegate: SliverChildBuilderDelegate(
      (context, i) => ListTile(
            leading: CircleAvatar(
              child: Text('0'),
            ),
            title: Text('List tile #$i'),
          ),
      childCount: 4,
    ),
  ),
);

SliverStickyHeader.builder

If you want to change the header layout during its scroll, you can use the SliverStickyHeader.builder constructor.

The example belows changes the opacity of the header as it scrolls off the viewport.

SliverStickyHeader.builder(
  builder: (context, state) => Container(
        height: 60.0,
        color: (state.isPinned ? Colors.pink : Colors.lightBlue)
            .withOpacity(1.0 - state.scrollPercentage),
        padding: EdgeInsets.symmetric(horizontal: 16.0),
        alignment: Alignment.centerLeft,
        child: Text(
          'Header #1',
          style: const TextStyle(color: Colors.white),
        ),
      ),
  sliver: SliverList(
    delegate: SliverChildBuilderDelegate(
      (context, i) => ListTile(
            leading: CircleAvatar(
              child: Text('0'),
            ),
            title: Text('List tile #$i'),
          ),
      childCount: 4,
    ),
  ),
);

You can find more examples in the Example project.

Sponsoring

I'm working on my packages on my free-time, but I don't have as much time as I would. If this package or any other package I created is helping you, please consider to sponsor me. By doing so, I will prioritize your issues or your pull-requests before the others.

Changelog

Please see the Changelog page to know what's recently changed.

Contributions

Feel free to contribute to this project.

If you find a bug or want a feature, but don't know how to fix/implement it, please fill an issue.
If you fixed a bug or implemented a new feature, please send a pull request.

Thanks

:clap: Thanks to slightfoot with it's RenderBox version (https://github.com/slightfoot/flutter_sticky_headers) which unintentionally challenged me to work in this RenderSliver version.

カテゴリー

依存関係

依存関係一覧 1 件

ソースリポジトリ

このパッケージを使用しているプロジェクト