FSelectTileGroup<T>.builder constructor
FSelectTileGroup<T>.builder ({
- required FSelectTileGroupController<
T> selectController, - required FSelectTile<
T> ? tileBuilder(- BuildContext context,
- int index
- int? count,
- ScrollController? scrollController,
- FTileGroupStyle? style,
- double? cacheExtent,
- double maxHeight = double.infinity,
- DragStartBehavior dragStartBehavior = DragStartBehavior.start,
- ScrollPhysics physics = const ClampingScrollPhysics(),
- FItemDivider divider = FItemDivider.indented,
- Widget? label,
- Widget? description,
- String? semanticsLabel,
- ValueChanged<
Set< ? onChange,T> > - ValueChanged<
(T, bool)> ? onSelect, - Widget errorBuilder(
- BuildContext context,
- String message
- 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. 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
FSelectTileGroup.builder({
required this.selectController,
required FSelectTile<T>? Function(BuildContext context, int index) tileBuilder,
int? count,
this.scrollController,
this.style,
this.cacheExtent,
this.maxHeight = double.infinity,
this.dragStartBehavior = DragStartBehavior.start,
this.physics = const ClampingScrollPhysics(),
this.divider = FItemDivider.indented,
this.label,
this.description,
this.semanticsLabel,
this.onChange,
this.onSelect,
Widget Function(BuildContext context, String message) 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,
);
},
);
},
);