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

waterfall_flow のカバー
パッケージ詳細v3.1.1

waterfall_flow

迅速にウォーターフォールレイアウトを構築するためのFlutterグリッドビュー。

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
2.2万
いいね数
233
Pub ポイント
140

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

flutter pub add waterfall_flow

パッケージ概要

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

Flutterパッケージで、高さが異なる列にアイテムを配置するグリッドビューであるウォーターフォールレイアウトを迅速に作成できます。Pinterestのような動的で視覚的に魅力的なフォーマットで画像やコンテンツを表示するのに最適です。このパッケージはAndroid、iOS、Web、macOS、Windows、Linuxなどすべての主要プラットフォームをサポートしており、クロスプラットフォームでの一貫性を確保します。カラム数、間隔、スクロール動作をカスタマイズ可能で、さまざまなUIニーズに対応できる柔軟性を持っています。

用途

  • 画像ギャラリーの表示
  • Pinterestスタイルのフィードを作成する
  • 動的コンテンツグリッドの構築
  • 製品一覧の表示
  • レスポンシブレイアウトの実装

主な機能

  • 最小限のコードで簡単なセットアップ
  • 可変アイテム高さをサポート
  • カスタマイズ可能な列数と間隔
  • クロスプラットフォーム互換性
  • スムーズなスクロールパフォーマンス
  • 柔軟なアイテムビルダー

適している対象

  • ソーシャルメディアフィードを構築する開発者
  • ビジュアルコンテンツ表示を作成するデザイナー
  • 応答性のあるグリッドレイアウトを必要とするアプリ
  • 動的または不規則なコンテンツサイズを持つプロジェクト
  • 複数のプラットフォームをターゲットにするチーム

注意事項

  • 大規模なデータセットに対して最適化が必要になる可能性があります
  • アイテム数が非常に多いとパフォーマンスが低下する可能性があります
  • レイアウトの問題を避けるために、アイテムの寸法を慎重に扱う必要があります
  • 固定高さのアイテムに適していません
  • 基本的な遷移以外の組み込みアニメーションは限られている

元の README

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

waterfall_flow

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

A Flutter grid view easy to build waterfall flow layout quickly.

Web demo for WaterfallFlow

Language: English | 中文简体

Use

  • add library to your pubspec.yaml

dependencies:
  waterfall_flow: any

  • import library in dart file

  import 'package:waterfall_flow/waterfall_flow.dart';

Easy to use

img img
img img

you can define waterfall flow layout within SliverWaterfallFlowDelegate.

  • SliverWaterfallFlowDelegateWithFixedCrossAxisCount
parameter description default
crossAxisCount The number of children in the cross axis. required
  • SliverWaterfallFlowDelegateWithMaxCrossAxisExtent
parameter description default
maxCrossAxisExtent The maximum extent of tiles in the cross axis. required
  • SliverWaterfallFlowDelegate
parameter description default
mainAxisSpacing The number of logical pixels between each child along the main axis. 0.0
crossAxisSpacing The number of logical pixels between each child along the cross axis. 0.0
collectGarbage Call when collect garbage, return indexs to collect -
lastChildLayoutTypeBuilder The builder to get layout type of last child ,Notice: it should only for last child -
viewportBuilder The builder to get indexs in viewport -
closeToTrailing Whether make layout close to trailing false
            WaterfallFlow.builder(
              //cacheExtent: 0.0,
              padding: EdgeInsets.all(5.0),
              gridDelegate: SliverWaterfallFlowDelegateWithFixedCrossAxisCount(
                  crossAxisCount: 2,
                  crossAxisSpacing: 5.0,
                  mainAxisSpacing: 5.0,
                  /// follow max child trailing layout offset and layout with full cross axis extend
                  /// last child as loadmore item/no more item in [GridView] and [WaterfallFlow]
                  /// with full cross axis extend
                  //  LastChildLayoutType.fullCrossAxisExtend,

                  /// as foot at trailing and layout with full cross axis extend
                  /// show no more item at trailing when children are not full of viewport
                  /// if children is full of viewport, it's the same as fullCrossAxisExtend
                  //  LastChildLayoutType.foot,
                  lastChildLayoutTypeBuilder: (index) => index == _list.length
                      ? LastChildLayoutType.foot
                      : LastChildLayoutType.none,
                  ),

CollectGarbage

track the indexes are collect, you can collect garbage at that monment(for example Image cache)

more detail

        WaterfallFlow.builder(
            gridDelegate: SliverWaterfallFlowDelegateWithFixedCrossAxisCount(
                collectGarbage: (List<int> garbages) {
                  ///collectGarbage
                  garbages.forEach((index) {
                    final provider = ExtendedNetworkImageProvider(
                      _list[index].imageUrl,
                    );
                    provider.evict();
                  });
                },
              ),

ViewportBuilder

track the indexes go into the viewport, it's not include cache extent.

        WaterfallFlow.builder(
            gridDelegate: SliverWaterfallFlowDelegateWithFixedCrossAxisCount(
                viewportBuilder: (int firstIndex, int lastIndex) {
                print("viewport : [$firstIndex,$lastIndex]");
                }),

LastChildLayoutTypeBuilder

build lastChild as special child in the case that it is loadmore/no more item.

        enum LastChildLayoutType {
        /// as default child
        none,

        /// follow max child trailing layout offset and layout with full cross axis extend
        /// last child as loadmore item/no more item in [ExtendedGridView] and [WaterfallFlow]
        /// with full cross axis extend
        fullCrossAxisExtend,

        /// as foot at trailing and layout with full cross axis extend
        /// show no more item at trailing when children are not full of viewport
        /// if children is full of viewport, it's the same as fullCrossAxisExtend
        foot,
        }

      WaterfallFlow.builder(
        gridDelegate: SliverWaterfallFlowDelegateWithFixedCrossAxisCount(
            lastChildLayoutTypeBuilder: (index) => index == length
                ? LastChildLayoutType.foot
                : LastChildLayoutType.none,
            ),

CloseToTrailing

when reverse property of List is true, layout is as following. it likes chat list, and new session will insert to zero index. but it's not right when items are not full of viewport.

     trailing
-----------------
|               |
|               |
|     item2     |
|     item1     |
|     item0     |
-----------------
     leading

to solve it, you could set closeToTrailing to true, layout is as following. support [ExtendedGridView],[ExtendedList],[WaterfallFlow]. and it also works when reverse is flase, layout will close to trailing.

     trailing
-----------------
|     item2     |
|     item1     |
|     item0     |
|               |
|               |
-----------------
     leading
      WaterfallFlow.builder(
        reverse: true,
        gridDelegate: SliverWaterfallFlowDelegateWithFixedCrossAxisCount(closeToTrailing: true),

カテゴリー

依存関係

依存関係一覧 2 件

ソースリポジトリ

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