XlbAnimated.options constructor

XlbAnimated.options(
  1. {@required LiveListItemBuilder itemBuilder,
  2. @required int itemCount,
  3. @required LiveOptions options,
  4. IndexedWidgetBuilder separatorBuilder,
  5. Axis scrollDirection = Axis.vertical,
  6. bool reverse = false,
  7. ScrollController controller,
  8. bool primary,
  9. ScrollPhysics physics,
  10. bool shrinkWrap = false,
  11. EdgeInsetsGeometry padding,
  12. bool addAutomaticKeepAlives = true,
  13. bool addRepaintBoundaries = true,
  14. bool addSemanticIndexes = true,
  15. Key key}
)

Creates a fixed-length scrollable linear array of list "items" separated by list item "separators".

This constructor is appropriate for list views with a large number of item and separator children because the builders are only called for the children that are actually visible.

The itemBuilder callback will be called with indices greater than or equal to zero and less than itemCount.

Separators only appear between list items: separator 0 appears after item 0 and the last separator appears before the last item.

The separatorBuilder callback will be called with indices greater than or equal to zero and less than itemCount - 1. May be null

The itemBuilder and separatorBuilder callbacks should actually create widget instances when called. Avoid using a builder that returns a previously-constructed widget; if the list view's children are created in advance, or all at once when the XlbAnimated itself is created, it is more efficient to use new XlbAnimated.

{@tool sample}

This example

XlbAnimated.options(
  itemCount: 25,
  option: LiveOptions(
    // Start animation after (default zero)
    delay: Duration(seconds: 1),
    // Show each item through
    showItemInterval: Duration(milliseconds: 500),
    // Animation duration
    showItemDuration: Duration(seconds: 1),
    // Animations starts at 0.025 visible item fraction in sight
    visibleFraction: 0.025,
  ),
  separatorBuilder: (BuildContext context, int index) => Divider(),
  itemBuilder: (_ context, int index, Animation<double> animation) {
    return ListTile(
      title: Text('item $index'),
    );
  },
)

{@end-tool}

The addAutomaticKeepAlives argument corresponds to the SliverChildBuilderDelegate.addAutomaticKeepAlives property. The addRepaintBoundaries argument corresponds to the SliverChildBuilderDelegate.addRepaintBoundaries property. The addSemanticIndexes argument corresponds to the SliverChildBuilderDelegate.addSemanticIndexes property. None may be null.

Implementation

XlbAnimated.options({
  @required this.itemBuilder,
  @required this.itemCount,
  @required LiveOptions options,
  this.separatorBuilder,
  this.scrollDirection = Axis.vertical,
  this.reverse = false,
  this.controller,
  this.primary,
  this.physics,
  this.shrinkWrap = false,
  this.padding,
  this.addAutomaticKeepAlives = true,
  this.addRepaintBoundaries = true,
  this.addSemanticIndexes = true,
  Key key,
})  : delay = options.delay,
      showItemInterval = options.showItemInterval,
      showItemDuration = options.showItemDuration,
      visibleFraction = options.visibleFraction,
      reAnimateOnVisibility = options.reAnimateOnVisibility,
      assert(itemBuilder != null),
      assert(itemCount != null && itemCount >= 0),
      super(key: key);