FSelectTileGroup<T>.builder constructor
FSelectTileGroup<T>.builder ({
- required FSelectTileGroupController<
T> selectController, - required FSelectTile<
T> ? tileBuilder(), - int? count,
- ScrollController? scrollController,
- FTileGroupStyle? style,
- double? cacheExtent,
- double maxHeight = double.infinity,
- DragStartBehavior dragStartBehavior = DragStartBehavior.start,
- ScrollPhysics physics = const ClampingScrollPhysics(),
- FTileDivider divider = FTileDivider.indented,
- Widget? label,
- Widget? description,
- String? semanticsLabel,
- ValueChanged<
Set< ? onChange,T> > - ValueChanged<
(T, bool)> ? onSelect, - Widget errorBuilder() = FFormFieldProperties.defaultErrorBuilder,
- FormFieldSetter<
Set< ? onSaved,T> > - FormFieldValidator<
Set< ? validator,T> > - String? forceErrorText,
- bool enabled = true,
- AutovalidateMode? autovalidateMode,
- Key? key,
Creates a FSelectTileGroup 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
FSelectTileGroup.builder({
required this.selectController,
required FSelectTile<T>? Function(BuildContext, int) tileBuilder,
int? count,
this.scrollController,
this.style,
this.cacheExtent,
this.maxHeight = double.infinity,
this.dragStartBehavior = DragStartBehavior.start,
this.physics = const ClampingScrollPhysics(),
this.divider = FTileDivider.indented,
this.label,
this.description,
this.semanticsLabel,
this.onChange,
this.onSelect,
Widget Function(BuildContext, String) errorBuilder = FFormFieldProperties.defaultErrorBuilder,
super.onSaved,
super.validator,
super.forceErrorText,
super.enabled = true,
super.autovalidateMode,
super.key,
}) : super(
initialValue: selectController.value,
errorBuilder: errorBuilder,
builder: (field) {
final state = field as _State;
return FTileGroup.builder(
scrollController: scrollController,
style: style ?? state.context.theme.tileGroupStyle,
cacheExtent: cacheExtent,
maxHeight: maxHeight,
dragStartBehavior: dragStartBehavior,
physics: physics,
count: count,
divider: divider,
label: label,
enabled: enabled,
description: description,
error: switch (state.errorText) {
_ when !enabled => null,
final text? => errorBuilder(state.context, text),
null => null,
},
semanticsLabel: semanticsLabel,
tileBuilder: (context, index) {
final child = tileBuilder(context, index);
return child == null
? null
: FSelectTileData<T>(
controller: selectController,
selected: selectController.contains(child.value),
child: child,
);
},
);
},
);