ReactiveSwitchListTile.adaptive constructor

ReactiveSwitchListTile.adaptive({
  1. Key? key,
  2. String? formControlName,
  3. FormControl<bool>? formControl,
  4. Color? activeColor,
  5. Color? activeTrackColor,
  6. Color? inactiveThumbColor,
  7. Color? inactiveTrackColor,
  8. ImageProvider<Object>? activeThumbImage,
  9. ImageErrorListener? onActiveThumbImageError,
  10. ImageProvider<Object>? inactiveThumbImage,
  11. ImageErrorListener? onInactiveThumbImageError,
  12. WidgetStateProperty<Color?>? thumbColor,
  13. WidgetStateProperty<Color?>? trackColor,
  14. WidgetStateProperty<Color?>? trackOutlineColor,
  15. WidgetStateProperty<Icon?>? thumbIcon,
  16. MaterialTapTargetSize? materialTapTargetSize,
  17. DragStartBehavior dragStartBehavior = DragStartBehavior.start,
  18. MouseCursor? mouseCursor,
  19. WidgetStateProperty<Color?>? overlayColor,
  20. double? splashRadius,
  21. bool autofocus = false,
  22. bool? applyCupertinoTheme,
  23. EdgeInsetsGeometry? contentPadding,
  24. ListTileControlAffinity controlAffinity = ListTileControlAffinity.platform,
  25. bool? dense,
  26. bool? enableFeedback,
  27. FocusNode? focusNode,
  28. ValueChanged<bool>? onFocusChange,
  29. Color? hoverColor,
  30. bool isThreeLine = false,
  31. Widget? secondary,
  32. bool selected = false,
  33. Color? selectedTileColor,
  34. ShapeBorder? shape,
  35. Widget? subtitle,
  36. Color? tileColor,
  37. Widget? title,
  38. VisualDensity? visualDensity,
  39. 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.adaptive({
  super.key,
  super.formControlName,
  super.formControl,
  Color? activeColor,
  Color? activeTrackColor,
  Color? inactiveThumbColor,
  Color? inactiveTrackColor,
  ImageProvider? activeThumbImage,
  ImageErrorListener? onActiveThumbImageError,
  ImageProvider? inactiveThumbImage,
  ImageErrorListener? onInactiveThumbImageError,
  WidgetStateProperty<Color?>? thumbColor,
  WidgetStateProperty<Color?>? trackColor,
  WidgetStateProperty<Color?>? trackOutlineColor,
  WidgetStateProperty<Icon?>? thumbIcon,
  MaterialTapTargetSize? materialTapTargetSize,
  DragStartBehavior dragStartBehavior = DragStartBehavior.start,
  MouseCursor? mouseCursor,
  WidgetStateProperty<Color?>? overlayColor,
  double? splashRadius,
  bool autofocus = false,
  bool? applyCupertinoTheme,
  EdgeInsetsGeometry? contentPadding,
  ListTileControlAffinity controlAffinity = ListTileControlAffinity.platform,
  bool? dense,
  bool? enableFeedback,
  super.focusNode,
  ValueChanged<bool>? onFocusChange,
  Color? hoverColor,
  bool isThreeLine = false,
  Widget? secondary,
  bool selected = false,
  Color? selectedTileColor,
  ShapeBorder? shape,
  Widget? subtitle,
  Color? tileColor,
  Widget? title,
  VisualDensity? visualDensity,
  ReactiveFormFieldCallback<bool>? onChanged,
}) : super(
       builder: (field) {
         return SwitchListTile.adaptive(
           value: field.value ?? false,
           activeColor: activeColor,
           activeTrackColor: activeTrackColor,
           inactiveThumbColor: inactiveThumbColor,
           inactiveTrackColor: inactiveTrackColor,
           activeThumbImage: activeThumbImage,
           onActiveThumbImageError: onActiveThumbImageError,
           inactiveThumbImage: inactiveThumbImage,
           onInactiveThumbImageError: onInactiveThumbImageError,
           thumbColor: thumbColor,
           trackColor: trackColor,
           trackOutlineColor: trackOutlineColor,
           thumbIcon: thumbIcon,
           materialTapTargetSize: materialTapTargetSize,
           dragStartBehavior: dragStartBehavior,
           mouseCursor: mouseCursor,
           overlayColor: overlayColor,
           splashRadius: splashRadius,
           autofocus: autofocus,
           applyCupertinoTheme: applyCupertinoTheme,
           contentPadding: contentPadding,
           controlAffinity: controlAffinity,
           dense: dense,
           enableFeedback: enableFeedback,
           focusNode: field.focusNode,
           onFocusChange: onFocusChange,
           hoverColor: hoverColor,
           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,
         );
       },
     );