extended_list 3.0.2 copy "extended_list: ^3.0.2" to clipboard
extended_list: ^3.0.2 copied to clipboard

extended list support track collect garbage/viewport indexes, build lastChild as special child and enable to layout close to trailing.

extended_list #

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

Language: English | 中文简体

extended list(ListView/GridView) support track collect garbage of children/viewport indexes, build lastChild as special child in the case that it is loadmore/no more item and enable to layout close to trailing.

Web demo for ExtendedList

Use #

  • add library to your pubspec.yaml

dependencies:
  extended_list: any

copied to clipboard
  • import library in dart file

  import 'package:extended_list/extended_list.dart';

copied to clipboard

CollectGarbage #

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

more detail

        ExtendedListView.builder(
            extendedListDelegate: ExtendedListDelegate(
                collectGarbage: (List<int> garbages) {
                print("collect garbage : $garbages");
                },),
copied to clipboard

ViewportBuilder #

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

        ExtendedListView.builder(
            extendedListDelegate: ExtendedListDelegate(
                viewportBuilder: (int firstIndex, int lastIndex) {
                print("viewport : [$firstIndex,$lastIndex]");
                }),
copied to clipboard

LastChildLayoutTypeBuilder #

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

img

img

        enum LastChildLayoutType {
        /// as default child
        none,

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

        /// 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 fullCrossAxisExtent
        foot,
        }

      ExtendedListView.builder(
        extendedListDelegate: ExtendedListDelegate(
            lastChildLayoutTypeBuilder: (index) => index == length
                ? LastChildLayoutType.foot
                : LastChildLayoutType.none,
            ),
copied to clipboard

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
copied to clipboard

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
copied to clipboard
      ExtendedListView.builder(
        reverse: true,
        extendedListDelegate: ExtendedListDelegate(closeToTrailing: true),
copied to clipboard
26
likes
150
points
4.04k
downloads

Publisher

verified publisherfluttercandies.com

Weekly Downloads

2024.09.08 - 2025.03.23

extended list support track collect garbage/viewport indexes, build lastChild as special child and enable to layout close to trailing.

Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

extended_list_library, flutter

More

Packages that depend on extended_list