listTileCheckboxBuilder<T> function
Widget
listTileCheckboxBuilder<T>(
- BuildContext context,
- CheckboxState<
T> state, { - Color? activeColor,
- Color? checkColor,
- Color? tileColor,
- Widget subtitle(
- CheckboxOption<
T> option
- CheckboxOption<
- bool isThreeLine = false,
- bool? dense,
- Widget? secondary,
- bool selected(
- CheckboxOption<
T> option
- CheckboxOption<
- ListTileControlAffinity controlAffinity = ListTileControlAffinity.platform,
- bool autofocus = false,
- EdgeInsetsGeometry? contentPadding,
- ShapeBorder? shape,
- Color? selectedTileColor,
Builder for CheckboxSuperFormField which builds a Column with CheckboxListTile for each CheckboxOption.
Implementation
Widget listTileCheckboxBuilder<T>(
BuildContext context,
CheckboxState<T> state, {
Color? activeColor,
Color? checkColor,
Color? tileColor,
Widget Function(CheckboxOption<T> option)? subtitle,
bool isThreeLine = false,
bool? dense,
Widget? secondary,
bool Function(CheckboxOption<T> option)? selected,
ListTileControlAffinity controlAffinity = ListTileControlAffinity.platform,
bool autofocus = false,
EdgeInsetsGeometry? contentPadding,
ShapeBorder? shape,
Color? selectedTileColor,
}) {
return Focus(
focusNode: state.focusNode,
skipTraversal: true,
child: Column(
children: state.options.map((option) {
final checked = state.checkedValues?.contains(option.value) ?? false;
return CheckboxListTile(
value: checked,
activeColor: activeColor,
checkColor: checkColor,
tileColor: tileColor,
title: option.label,
subtitle: subtitle != null ? subtitle(option) : null,
isThreeLine: isThreeLine,
dense: dense,
secondary: secondary,
// ignore: avoid_bool_literals_in_conditional_expressions
selected: selected != null ? selected(option) : false,
controlAffinity: controlAffinity,
autofocus: autofocus,
contentPadding: contentPadding,
shape: shape,
selectedTileColor: selectedTileColor,
onChanged: state.onChanged != null
? (checked) {
state.onChanged!(option.value, checked!);
}
: null,
);
}).toList(),
),
);
}