ReactiveSwitch constructor

ReactiveSwitch({
  1. Key? key,
  2. String? formControlName,
  3. FormControl<bool>? formControl,
  4. FocusNode? focusNode,
  5. Color? activeColor,
  6. Color? activeTrackColor,
  7. Color? inactiveThumbColor,
  8. Color? inactiveTrackColor,
  9. ImageProvider<Object>? activeThumbImage,
  10. ImageErrorListener? onActiveThumbImageError,
  11. ImageProvider<Object>? inactiveThumbImage,
  12. ImageErrorListener? onInactiveThumbImageError,
  13. MaterialTapTargetSize? materialTapTargetSize,
  14. DragStartBehavior dragStartBehavior = DragStartBehavior.start,
  15. Color? focusColor,
  16. Color? hoverColor,
  17. bool autofocus = false,
  18. EdgeInsetsGeometry? padding,
  19. WidgetStateProperty<double?>? trackOutlineWidth,
  20. WidgetStateProperty<Color?>? thumbColor,
  21. WidgetStateProperty<Color?>? trackColor,
  22. MouseCursor? mouseCursor,
  23. WidgetStateProperty<Color?>? overlayColor,
  24. double? splashRadius,
  25. ReactiveFormFieldCallback<bool>? onChanged,
  26. WidgetStateProperty<Color?>? trackOutlineColor,
  27. WidgetStateProperty<Icon?>? thumbIcon,
  28. ValueChanged<bool>? onFocusChange,
})

Creates a ReactiveSwitch that wraps a material design switch.

Can optionally provide a formControl to bind this widget to a control.

Can optionally provide a formControlName to bind this ReactiveFormField to a FormControl.

Must provide one of the arguments formControl or a formControlName, but not both at the same time.

For documentation about the various parameters, see the Switch class and Switch, the constructor.

Implementation

ReactiveSwitch({
  super.key,
  super.formControlName,
  super.formControl,
  super.focusNode,
  Color? activeColor,
  Color? activeTrackColor,
  Color? inactiveThumbColor,
  Color? inactiveTrackColor,
  ImageProvider? activeThumbImage,
  ImageErrorListener? onActiveThumbImageError,
  ImageProvider? inactiveThumbImage,
  ImageErrorListener? onInactiveThumbImageError,
  MaterialTapTargetSize? materialTapTargetSize,
  DragStartBehavior dragStartBehavior = DragStartBehavior.start,
  Color? focusColor,
  Color? hoverColor,
  bool autofocus = false,
  EdgeInsetsGeometry? padding,
  WidgetStateProperty<double?>? trackOutlineWidth,
  WidgetStateProperty<Color?>? thumbColor,
  WidgetStateProperty<Color?>? trackColor,
  MouseCursor? mouseCursor,
  WidgetStateProperty<Color?>? overlayColor,
  double? splashRadius,
  ReactiveFormFieldCallback<bool>? onChanged,
  WidgetStateProperty<Color?>? trackOutlineColor,
  WidgetStateProperty<Icon?>? thumbIcon,
  ValueChanged<bool>? onFocusChange,
}) : super(
       builder: (field) {
         return Switch(
           value: field.value ?? false,
           activeColor: activeColor,
           trackOutlineColor: trackOutlineColor,
           thumbIcon: thumbIcon,
           onFocusChange: onFocusChange,
           activeTrackColor: activeTrackColor,
           inactiveThumbColor: inactiveThumbColor,
           inactiveTrackColor: inactiveTrackColor,
           activeThumbImage: activeThumbImage,
           onActiveThumbImageError: onActiveThumbImageError,
           inactiveThumbImage: inactiveThumbImage,
           onInactiveThumbImageError: onInactiveThumbImageError,
           materialTapTargetSize: materialTapTargetSize,
           dragStartBehavior: dragStartBehavior,
           focusColor: focusColor,
           hoverColor: hoverColor,
           autofocus: autofocus,
           thumbColor: thumbColor,
           trackColor: trackColor,
           mouseCursor: mouseCursor,
           overlayColor: overlayColor,
           splashRadius: splashRadius,
           focusNode: field.focusNode,
           padding: padding,
           trackOutlineWidth: trackOutlineWidth,
           onChanged:
               field.control.enabled
                   ? (value) {
                     field.didChange(value);
                     onChanged?.call(field.control);
                   }
                   : null,
         );
       },
     );