FTileGroup.builder constructor
FTileGroup.builder({
- required NullableIndexedWidgetBuilder tileBuilder,
- int? count,
- FTileGroupStyle style(
- FTileGroupStyle style
- ScrollController? scrollController,
- double? cacheExtent,
- double maxHeight = double.infinity,
- DragStartBehavior dragStartBehavior = DragStartBehavior.start,
- ScrollPhysics physics = const ClampingScrollPhysics(),
- bool? enabled,
- FItemDivider divider = FItemDivider.indented,
- String? semanticsLabel,
- Widget? label,
- Widget? description,
- Widget? error,
- Key? key,
Creates a FTileGroup that lazily builds its children.
The tileBuilder is called for each tile that should be built. The current level's FInheritedItemData is not
visible to tileBuilder.
- It may return null to signify the end of the group.
- It may be called more than once for the same index.
- It will be called only for indices <=
countifcountis given.
The count is the number of tiles to build. If null, tileBuilder will be called until it returns null.
Notes
May result in an infinite loop or run out of memory if:
- Placed in a parent widget that does not constrain its size, i.e. Column.
countis null andtileBuilderalways provides a zero-size widget, i.e. SizedBox(). If possible, provide tiles with non-zero size, return null from builder, or setcountto non-null.
Implementation
FTileGroup.builder({
required NullableIndexedWidgetBuilder tileBuilder,
int? count,
this.style,
this.scrollController,
this.cacheExtent,
this.maxHeight = double.infinity,
this.dragStartBehavior = DragStartBehavior.start,
this.physics = const ClampingScrollPhysics(),
this.enabled,
this.divider = FItemDivider.indented,
this.semanticsLabel,
this.label,
this.description,
this.error,
super.key,
}) : assert(0 < maxHeight, 'maxHeight ($maxHeight) must be > 0'),
assert(count == null || 0 <= count, 'count ($count) must be >= 0'),
_builder = ((style, enabled) => SliverList.builder(
itemCount: count,
itemBuilder: (context, index) {
if (tileBuilder(context, index) case final tile?) {
return FInheritedItemData.merge(
style: style.tileStyle,
enabled: enabled,
dividerColor: style.dividerColor,
dividerWidth: style.dividerWidth,
divider: divider,
index: index,
last: (count != null && index == count - 1) || tileBuilder(context, index + 1) == null,
child: tile,
);
}
return null;
},
));