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

sliver_sticky_collapsable_panel のカバー
パッケージ詳細v5.0.1

sliver_sticky_collapsable_panel

ステイキーフラットパネルのスリバー実装で、状態に応じてボックスヘッダーが再構築され、スリバー子要素としてパネルコンテンツが提供されます。

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
2480
いいね数
121
Pub ポイント
160

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

flutter pub add sliver_sticky_collapsable_panel

パッケージ概要

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

スライバーに基づくウィジェットで、スクロール状態に応じてヘッダーを動的に再構築するスタック可能かつ折りたたみ可能なパネルを実装しています。パネルが展開または折りたたまれる際に更新されるカスタマイズ可能なボックスヘッダーを備えており、パネルコンテンツ用のスライバー子要素を受け入れます。複雑なリストでの効率的なスクロールを目的として設計されており、複数プラットフォームにおけるCustomScrollViewレイアウトにシームレスに統合されます。

用途

  • インタラクティブなヘッダー付きスクロールリスト
  • スクロール中の動的ヘッダー状態
  • スタックパネルを必要とする複雑なUI
  • 展開/折りたたみ可能なコンテンツセクション
  • カスタマイズ可能なスクロール駆動型インタラクション

主な機能

  • スタックパネルの動作
  • スクロール時のヘッダー再構築
  • Sliver互換レイアウト
  • 折りたたみ可能なコンテンツセクション
  • プラットフォームに依存しない実装

適している対象

  • スクロール可能なインターフェースを構築する開発者
  • 応答性のあるヘッダーを必要とするアプリ
  • CustomScrollView の統合
  • クロスプラットフォームモバイルおよびWebアプリ
  • レイヤードスクロール可能コンテンツを備えたUI

注意事項

  • CustomScrollView 内での統合が必要です
  • シルバーに基づくレイアウトに限定
  • ヘッダーの論理はカスタム調整が必要な場合があります
  • パフォーマンスは子供の複雑さに依存します
  • スクロールしないコンテキストには適していません

元の README

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

sliver_sticky_collapsable_panel

pub license build status flutter compatibility dart compatibility

A Sliver implementation of sticky collapsable panel, with a box header rebuild on status and a sliver child as panel content.

Snap Shot

simple Shot

Features

  • Relying solely on the Flutter framework itself, no any other dependencies.
  • Pure Dart implementation, running on any platform who supports Flutter.
  • Command style support for expand/collpase the panel.(it's still compatible with declarative style)
  • Accept one box child as header and one sliver child as panel content.
  • Header can overlap panel content (useful for sticky side header for example).
  • Notify and rebuild the header when status changed (scroll outside the viewport for example).
  • Support not sticky headers (with sticky: false parameter).
  • Support a controller which notifies the scroll offset of the current sticky header.
  • Support click the header to collapse the panel, or disable collapse (with disableCollapsable = true parameter in panelController).
  • Support iOS style sticky header, just like iOS's system contact app (with iOSStyleSticky = true parameter).
  • Support add padding for sliver child (with paddingBeforeCollapse parameter).
  • Support add padding after the header even the panel collapsed (with paddingAfterCollapse parameter).

Getting started

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

    dependencies:
      sliver_sticky_collapsable_panel: ^5.0.1
    
  • In your library add the following import:

    import 'package:sliver_sticky_collapsable_panel/sliver_sticky_collapsable_panel.dart';
    
  • In your code, use the sliver like this:

    CustomScrollView(
      controller: _scrollController,
      slivers: [
        SliverStickyCollapsablePanel(
          scrollController: _scrollController,
          panelController: StickyCollapsablePanelController(key:'key_1'),
          headerBuilder: (context, status) => SizedBox.fromSize(size: Size.fromHeight(48)),
          sliverPanel: SliverList.list(children: [...]),
        ),
        SliverStickyCollapsablePanel(
          scrollController: _scrollController,
          panelController: StickyCollapsablePanelController(key:'key_2'),
          headerBuilder: (context, status) => SizedBox.fromSize(size: Size.fromHeight(48)),
          sliverPanel: SliverList.list(children: [...]),
        ),
        ...,
      ],
    );
    
  • For simple right side header arrow hint ^, you can build with widget in flutter framework like AnimatedRotation:

    SliverStickyCollapsablePanel(
      scrollController: _scrollController,
      panelController: StickyCollapsablePanelController(key:'key_1'),
      headerBuilder: (context, status) => Container(
        width: double.infinity,
        height: 48,
        child: Stack(
          children: [
            Text("your title, or any other box widget you like"),
            Align(
              alignment: Alignment.centerRight,
              child: AnimatedRotation(
                duration: const Duration(milliseconds: 0),
                turns: status.isExpanded ? 0 : 0.5,
                child: const Icon(Icons.expand_more),
              ),
            ), 
          ],
        ),
      ),
      sliverPanel: SliverList.list(children: [...]),
    ),
    

More Advanced Feature:

  • You can disable collapse for any sliver you wanted, just add disableCollapsable = true.
    CustomScrollView(
      controller: _scrollController,
      slivers: [
        SliverStickyCollapsablePanel(
          scrollController: _scrollController,
          panelController: StickyCollapsablePanelController(key:'key_1',disableCollapsable: true),
          headerBuilder: (context, status) => SizedBox.fromSize(size: Size.fromHeight(48)),
          sliverPanel: SliverList.list(children: [...]),
        ),
        ...,
      ],
    );
    

  • You can enable iOS style sticky header, just like the system's contact app with just one parameter iOSStyleSticky = true.
    CustomScrollView(
      controller: _scrollController,
      slivers: [
        SliverStickyCollapsablePanel(
          scrollController: _scrollController,
          panelController: StickyCollapsablePanelController(key:'key_1'),
          iOSStyleSticky: true,
          headerBuilder: (context, status) => SizedBox.fromSize(size: Size.fromHeight(48)),
          sliverPanel: SliverList.list(children: [...]),
        ),
        ...,
      ],
    );
    
    simple Shot

  • You can add padding for sliver child (with paddingBeforeCollapse), even if the panel is collapsed, the padding still work between headers with paddingAfterCollapse.
    CustomScrollView(
      controller: _scrollController,
      slivers: [
        SliverStickyCollapsablePanel(
          scrollController: _scrollController,
          panelController: StickyCollapsablePanelController(key:'key_1'),
          paddingBeforeCollapse: const EdgeInsets.all(16),
          paddingAfterCollapse: const EdgeInsets.only(bottom: 10),
          headerBuilder: (context, status) => SizedBox.fromSize(size: Size.fromHeight(48)),
          sliverPanel: SliverList.list(children: [...]),
        ),
        ...,
      ],
    );
    
    simple Shot

  • You can animate collapse/expand with only one parameter: panelAnimationDuration
    CustomScrollView(
      controller: _scrollController,
      slivers: [
        SliverStickyCollapsablePanel(
          scrollController: _scrollController,
          panelController: StickyCollapsablePanelController(key:'key_1'),
          panelAnimationDuration: Duration(milliseconds: 300),
          paddingBeforeCollapse: const EdgeInsets.all(16),
          paddingAfterCollapse: const EdgeInsets.only(bottom: 10),
          headerBuilder: (context, status) => SizedBox.fromSize(size: Size.fromHeight(48)),
          sliverPanel: SliverList.list(children: [...]),
        ),
        ...,
      ],
    );
    

Performance configuration

  • You can use optional parameter headerSize to speed up the layout process when the size not change
    • if your header size maybe change, just keep this parameter null (which is the default)
      CustomScrollView(
        controller: _scrollController,
        slivers: [
          SliverStickyCollapsablePanel(
            scrollController: _scrollController,
            panelController: StickyCollapsablePanelController(key:'key_1'),
            iOSStyleSticky: true,
            headerBuilder: (context, status) => SizedBox.fromSize(size: Size.fromHeight(48)),
            headerSize: Size(MediaQuery.of(context).size.width, 48),
            sliverPanel: SliverList.list(children: [...]),
          ),
          ...,
        ],
      );
      

Thanks

カテゴリー

ソースリポジトリ

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

データはまだありません。