listTileCheckboxBuilder<T> function

Widget listTileCheckboxBuilder<T>(
  1. BuildContext context,
  2. CheckboxState<T> state, {
  3. Color? activeColor,
  4. Color? checkColor,
  5. Color? tileColor,
  6. Widget subtitle(
    1. CheckboxOption<T> option
    )?,
  7. bool isThreeLine = false,
  8. bool? dense,
  9. Widget? secondary,
  10. bool selected(
    1. CheckboxOption<T> option
    )?,
  11. ListTileControlAffinity controlAffinity = ListTileControlAffinity.platform,
  12. bool autofocus = false,
  13. EdgeInsetsGeometry? contentPadding,
  14. ShapeBorder? shape,
  15. 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(),
    ),
  );
}