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

extended_sliver のカバー
パッケージ詳細v2.1.3

extended_sliver

Sliver の強力な拡張ライブラリで、SliverPinnedPersistentHeader、SliverPinnedToBoxAdapter、ExtendedSliverAppbar を含みます。

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

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

flutter pub add extended_sliver

パッケージ概要

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

ExtendedSliver は、追加のカスタマイズ可能なコンポーネントを備えた Flutter パッケージで、Sliver ウィジェットファミリーを拡張します。スクロール中に固定されるヘッダー用の SliverPinnedPersistentHeader、スクロール可能領域内に任意のウィジェットを固定するための SliverPinnedToBoxAdapter、高度なアプリバー機能を提供する ExtendedSliverAppbar を導入しています。複雑なリストやアプリバーにおけるスクロール動作の精密な制御を求める開発者向けに設計されており、最小限のボイラープレートで標準スリーブの機能を拡張します。複数プラットフォームで洗練されたスクロール体験が必要なアプリに最適です。

用途

  • スクロールビュー内のカスタマイズ可能な永続ヘッダー
  • 動的な挙動を備えた高度なアプリバー設計
  • スクロール可能なリスト内の特定の位置にウィジェットをピン留めする
  • 複雑なスクロールベースのレイアウトを作成する
  • レイヤードスクロール効果を使用した応答性のあるUIの構築
  • 最適化されたスリバー使用によるリストパフォーマンスの向上

主な機能

  • スリバーPinnedPersistentHeader はスタックヘッダーに使用されます
  • 任意のウィジェットをピン留めするための SliverPinnedToBoxAdapter
  • 拡張されたカスタマイズ機能を備えた ExtendedSliverAppbar
  • すべての主要プラットフォームに対応
  • 最小限のセットアップと直感的な API
  • 大規模なリスト向けの最適化されたパフォーマンス

適している対象

  • 複雑なスクロール可能なインターフェースを構築する開発者
  • スクロール動作の正確な制御が必要なUIデザイナー
  • 動的またはレイヤードコンテンツレイアウトを持つアプリ
  • クロスプラットフォームのFlutterアプリケーション
  • カスタムスクロールロジックを減らそうとしているチーム
  • 再利用可能で保守可能なスリバー コンポーネントを必要とするプロジェクト

注意事項

  • Sliver ウィジェットに精通している必要があります
  • シンプルなスクロールビューの複雑さを増す可能性があります
  • 高度なユースケースに最適
  • 基本的な例以外のドキュメントは限られている
  • 過剰に使用するとパフォーマンスに影響が出る可能性があります
  • Flutterの基本を学ぶ初心者には理想的ではありません

元の README

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

extended_sliver

pub package GitHub stars GitHub forks GitHub license GitHub issues FlutterCandies QQ 群

Language: English | 中文简体

Description

A powerful extension library of Sliver, which include SliverToNestedScrollBoxAdapter, SliverPinnedPersistentHeader, SliverPinnedToBoxAdapter and ExtendedSliverAppbar.

Usage

Add packages to dependencies

Add the package to pubspec.yaml under dependencies.

dependencies:
  extended_sliver: latest-version

Download with flutter packages get

SliverPinnedPersistentHeader

It's the same as SliverPersistentHeader(pinned: true), but you don't have to force values of minExtent and maxExtent.

It provides minExtentProtoType and maxExtentProtoType to calculate minExtent and maxExtent automatically.

It's useful that you don't know the final extent before the widgets are laid out.

    SliverPinnedPersistentHeader(
      delegate: MySliverPinnedPersistentHeaderDelegate(
        minExtentProtoType: Container(
          height: 120.0,
          color: Colors.red.withOpacity(0.5),
          child: FlatButton(
            child: const Text('minProtoType'),
            onPressed: () {
              print('minProtoType');
            },
          ),
          alignment: Alignment.topCenter,
        ),
        maxExtentProtoType: Container(
          height: 200.0,
          color: Colors.blue,
          child: FlatButton(
            child: const Text('maxProtoType'),
            onPressed: () {
              print('maxProtoType');
            },
          ),
          alignment: Alignment.bottomCenter,
        ),
      ),
    )

SliverPinnedToBoxAdapter

You can create a pinned Sliver easily with it.

It's useful that you don't know the final extent before the child are laid out.

    SliverPinnedToBoxAdapter(
      child: Container(
        padding: const EdgeInsets.all(20),
        color: Colors.blue.withOpacity(0.5),
        child: Column(
          children: <Widget>[
            const Text(
                '[love]Extended text help you to build rich text quickly. any special text you will have with extended text. '
                '\n\nIt\'s my pleasure to invite you to join \$FlutterCandies\$ if you want to improve flutter .[love]'
                '\n\nif you meet any problem, please let me konw @zmtzawqlp .[sun_glasses]'),
            FlatButton(
              child: const Text('I\'m button. click me!'),
              onPressed: () {
                debugPrint('click');
              },
            ),
          ],
        ),
      ),
    )

ExtendedSliverAppbar

You can create SliverAppbar with out force the expandedHeight.

return CustomScrollView(
  slivers: <Widget>[
    ExtendedSliverAppbar(
      title: const Text(
        'ExtendedSliverAppbar',
        style: TextStyle(color: Colors.white),
      ),
      leading: const BackButton(
        onPressed: null,
        color: Colors.white,
      ),
      background: Image.asset(
        'assets/cypridina.jpeg',
        fit: BoxFit.cover,
      ),
      actions: Padding(
        padding: const EdgeInsets.all(10.0),
        child: Icon(
          Icons.more_horiz,
          color: Colors.white,
        ),
      ),
    ),
  ],
);

SliverToNestedScrollBoxAdapter

You can create nested scrollable widget(like Webview) in CustomScrollView/NestedScrollView.

return CustomScrollView(
  slivers: <Widget>[
      SliverToBoxAdapter(
        child: Container(
          height: 100,
          color: Colors.red,
          child: const Center(
            child: Text(
              'Header',
              style: TextStyle(color: Colors.white),
            ),
          ),
        ),
      ),
    ValueListenableBuilder<double>(
      valueListenable: nestedWebviewController.scrollHeightNotifier,
      builder: (
        BuildContext context,
        double scrollHeight,
        Widget? child,
      ) {
        return SliverToNestedScrollBoxAdapter(
          childExtent: scrollHeight,
          onScrollOffsetChanged: (double scrollOffset) {
            double y = scrollOffset;
            if (Platform.isAndroid) {
              // https://github.com/flutter/flutter/issues/75841
              y *= window.devicePixelRatio;
      
            nestedWebviewController.webviewController
                ?.scrollTo(0, y.ceil());
          },
          child: child,
        );
      },
      child: WebView(
        initialUrl: nestedWebviewController.initialUrl,
        onPageStarted: nestedWebviewController.onPageStarted,
        onPageFinished: nestedWebviewController.onPageFinished,
        onWebResourceError:
            nestedWebviewController.onWebResourceError,
        onWebViewCreated: nestedWebviewController.onWebViewCreated,
        onProgress: nestedWebviewController.onProgress,
        javascriptChannels: <JavascriptChannel>{
          nestedWebviewController
              .scrollHeightNotifierJavascriptChannel
        },
        javascriptMode: JavascriptMode.unrestricted,
      ),
    ),
    SliverToBoxAdapter(
        child: Container(
          height: 300,
          color: Colors.green,
          child: const Center(
            child: Text(
              'Footer',
              style: TextStyle(color: Colors.white),
            ),
          ),
        ),
    ),
  ],
);

Complex Demo

Complex Demo

image

カテゴリー

ソースリポジトリ

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