FTileGroup.builder constructor
FTileGroup.builder({
- required NullableIndexedWidgetBuilder tileBuilder,
- int? count,
- FTileGroupStyle? style,
- ScrollController? scrollController,
- double? cacheExtent,
- double maxHeight = double.infinity,
- DragStartBehavior dragStartBehavior = DragStartBehavior.start,
- ScrollPhysics physics = const ClampingScrollPhysics(),
- bool? enabled,
- FTileDivider divider = FTileDivider.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. FTileData 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 <=
count
ifcount
is 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.
count
is null andtileBuilder
always provides a zero-size widget, i.e. SizedBox(). If possible, provide tiles with non-zero size, return null from builder, or setcount
to 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 = FTileDivider.indented,
this.semanticsLabel,
this.label,
this.description,
this.error,
super.key,
}) : assert(0 < maxHeight, 'maxHeight must be positive.'),
assert(count == null || 0 <= count, 'count must be non-negative.'),
delegate = ((style, {required enabled}) => SliverChildBuilderDelegate((context, index) {
final tile = tileBuilder(context, index);
if (tile == null) {
return null;
}
return FTileData(
style: style,
divider: divider,
states: {if (!enabled) WidgetState.disabled},
index: index,
last: (count != null && index == count - 1) || tileBuilder(context, index + 1) == null,
pressable: true,
child: tile,
);
}, childCount: count));