ReactiveSwitchListTile.adaptative constructor

ReactiveSwitchListTile.adaptative({
  1. Key? key,
  2. String? formControlName,
  3. FormControl<bool>? formControl,
  4. Color? activeColor,
  5. ImageProvider<Object>? activeThumbImage,
  6. Color? activeTrackColor,
  7. bool autofocus = false,
  8. EdgeInsetsGeometry? contentPadding,
  9. ListTileControlAffinity controlAffinity = ListTileControlAffinity.platform,
  10. bool? dense,
  11. bool? enableFeedback,
  12. FocusNode? focusNode,
  13. Color? hoverColor,
  14. Color? inactiveThumbColor,
  15. ImageProvider<Object>? inactiveThumbImage,
  16. Color? inactiveTrackColor,
  17. bool isThreeLine = false,
  18. Widget? secondary,
  19. bool selected = false,
  20. Color? selectedTileColor,
  21. ShapeBorder? shape,
  22. Widget? subtitle,
  23. Color? tileColor,
  24. Widget? title,
  25. VisualDensity? visualDensity,
  26. ReactiveFormFieldCallback<bool>? onChanged,
})

Creates a ReactiveSwitchListTile that wraps a Material ListTile with an adaptive Switch, following Material design's Cross-platform guidelines.

This widget uses Switch.adaptive to change the graphics of the switch component based on the ambient ThemeData.platform. On iOS and macOS, a CupertinoSwitch will be used. On other platforms a Material design Switch will be used.

If a CupertinoSwitch is created, the following parameters are ignored: activeTrackColor, inactiveThumbColor, inactiveTrackColor, activeThumbImage, inactiveThumbImage.

For documentation about the various parameters, see the SwitchListTile.adaptive constructor.

Implementation

ReactiveSwitchListTile.adaptative({
  Key? key,
  String? formControlName,
  FormControl<bool>? formControl,
  Color? activeColor,
  ImageProvider? activeThumbImage,
  Color? activeTrackColor,
  bool autofocus = false,
  EdgeInsetsGeometry? contentPadding,
  ListTileControlAffinity controlAffinity = ListTileControlAffinity.platform,
  bool? dense,
  bool? enableFeedback,
  FocusNode? focusNode,
  Color? hoverColor,
  Color? inactiveThumbColor,
  ImageProvider? inactiveThumbImage,
  Color? inactiveTrackColor,
  bool isThreeLine = false,
  Widget? secondary,
  bool selected = false,
  Color? selectedTileColor,
  ShapeBorder? shape,
  Widget? subtitle,
  Color? tileColor,
  Widget? title,
  VisualDensity? visualDensity,
  ReactiveFormFieldCallback<bool>? onChanged,
}) : super(
        key: key,
        formControl: formControl,
        formControlName: formControlName,
        focusNode: focusNode,
        builder: (field) {
          return SwitchListTile.adaptive(
            value: field.value ?? false,
            activeColor: activeColor,
            activeThumbImage: activeThumbImage,
            activeTrackColor: activeTrackColor,
            autofocus: autofocus,
            contentPadding: contentPadding,
            controlAffinity: controlAffinity,
            dense: dense,
            enableFeedback: enableFeedback,
            focusNode: field.focusNode,
            hoverColor: hoverColor,
            inactiveThumbColor: inactiveThumbColor,
            inactiveThumbImage: inactiveThumbImage,
            inactiveTrackColor: inactiveTrackColor,
            isThreeLine: isThreeLine,
            secondary: secondary,
            selected: selected,
            selectedTileColor: selectedTileColor,
            shape: shape,
            subtitle: subtitle,
            tileColor: tileColor,
            title: title,
            visualDensity: visualDensity,
            onChanged: field.control.enabled
                ? (value) {
                    field.didChange(value);
                    onChanged?.call(field.control);
                  }
                : null,
          );
        },
      );