waterfall_flow 0.1.3

waterfall_flow #

pub package GitHub stars GitHub forks GitHub license GitHub issues flutter-candies

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 #

imgimg
imgimg

you can define waterfall flow layout within SliverWaterfallFlowDelegate.

parameterdescriptiondefault
crossAxisCountThe number of children in the cross axis.required
mainAxisSpacingThe number of logical pixels between each child along the main axis.0.0
crossAxisSpacingThe number of logical pixels between each child along the cross axis.0.0
collectGarbageCall when collect garbage, return indexs to collect-
lastChildLayoutTypeBuilderThe builder to get layout type of last child ,Notice: it should only for last child-
viewportBuilderThe builder to get indexs in viewport-
closeToTrailingWhether make layout close to trailingfalse
            WaterfallFlow.builder(
              //cacheExtent: 0.0,
              padding: EdgeInsets.all(5.0),
              gridDelegate: SliverWaterfallFlowDelegate(
                  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: SliverWaterfallFlowDelegate(
                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: SliverWaterfallFlowDelegate(
                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: SliverWaterfallFlowDelegate(
            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: SliverWaterfallFlowDelegate(closeToTrailing: true),

[0.1.3]

  • web support.

[0.1.2]

  • update demo.

[0.1.1]

  • update description.

[0.1.0]

  • first release.

example/README.md

example #

A new Flutter project.

Getting Started #

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  waterfall_flow: ^0.1.3

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:waterfall_flow/waterfall_flow.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
79
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
90
Learn more about scoring.

We analyzed this package on Feb 19, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.5
  • Flutter: 1.12.13+hotfix.7

Health suggestions

Format lib/src/rendering/sliver_waterfall_flow.dart.

Run flutter format to format lib/src/rendering/sliver_waterfall_flow.dart.

Format lib/src/widgets/scroll_view.dart.

Run flutter format to format lib/src/widgets/scroll_view.dart.

Format lib/src/widgets/sliver.dart.

Run flutter format to format lib/src/widgets/sliver.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
extended_list_library ^0.1.3 0.1.3
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test