RadioSuperFormField<T>.listTile constructor

RadioSuperFormField<T>.listTile({
  1. Key? key,
  2. required String name,
  3. required List<RadioOption<T>> options,
  4. List<SuperFormFieldRule>? rules,
  5. bool toggleable = false,
  6. Color? activeColor,
  7. Widget subtitle(
    1. RadioOption<T> option
    )?,
  8. bool isThreeLine = false,
  9. bool? dense,
  10. Widget? secondary,
  11. bool selected(
    1. RadioOption<T> option
    )?,
  12. ListTileControlAffinity controlAffinity = ListTileControlAffinity.platform,
  13. bool autofocus = false,
  14. EdgeInsetsGeometry? contentPadding,
  15. ShapeBorder? shape,
  16. Color? tileColor,
  17. Color? selectedTileColor,
  18. void onChanged(
    1. T? value
    )?,
  19. bool? enabled,
})

Creates a Column of connected RadioListTiles which represent the options.

Check RadioListTile documentation for arguments documentation.

Diffences between RadioListTile and this builder are:

  • subtitle is a function so developers can customize it per option
  • selected is a function so developers can customize it per option

Implementation

RadioSuperFormField.listTile({
  Key? key,
  required String name,
  required this.options,
  List<SuperFormFieldRule>? rules,
  bool toggleable = false,
  Color? activeColor,
  Widget Function(RadioOption<T> option)? subtitle,
  bool isThreeLine = false,
  bool? dense,
  Widget? secondary,
  bool Function(RadioOption<T> option)? selected,
  ListTileControlAffinity controlAffinity = ListTileControlAffinity.platform,
  bool autofocus = false,
  EdgeInsetsGeometry? contentPadding,
  ShapeBorder? shape,
  Color? tileColor,
  Color? selectedTileColor,
  void Function(T? value)? onChanged,
  this.enabled,
}) : super(
        key: key,
        name: name,
        rules: rules ?? [],
        builder: (context, fieldState, formState) {
          final T? currentGroupValue = fieldState.data?.value as T?;

          void effectiveOnChanged(T? value) {
            SuperFormFieldData newData = fieldState.data!.copyWithValue(
              value: value,
              touched: true,
            );

            // If the field was tried to be submitted it should be now revalidated every change
            if (formState.validationMode == ValidationMode.onChange ||
                newData.submitted) {
              newData = newData.validate(rules ?? []);
            }

            formState.updateFieldData(newData);

            if (onChanged != null) {
              onChanged(value);
            }
          }

          final effectiveEnabled = enabled ?? formState.enabled;

          return listTileRadioBuilder(
            context,
            RadioState<T>(
              options,
              currentGroupValue,
              effectiveEnabled ? effectiveOnChanged : null,
              fieldState.focusNode,
            ),
            toggleable: toggleable,
            activeColor: activeColor,
            subtitle: subtitle,
            isThreeLine: isThreeLine,
            dense: dense,
            secondary: secondary,
            selected: selected,
            controlAffinity: controlAffinity,
            autofocus: autofocus,
            contentPadding: contentPadding,
            shape: shape,
            tileColor: tileColor,
            selectedTileColor: selectedTileColor,
          );
        },
      );