ReactiveSwitch.adaptive constructor
- Key? key,
- String? formControlName,
- FormControl<
bool> ? formControl, - FocusNode? focusNode,
- Color? activeColor,
- Color? activeTrackColor,
- Color? inactiveThumbColor,
- Color? inactiveTrackColor,
- ImageProvider<
Object> ? activeThumbImage, - ImageErrorListener? onActiveThumbImageError,
- ImageProvider<
Object> ? inactiveThumbImage, - ImageErrorListener? onInactiveThumbImageError,
- MaterialTapTargetSize? materialTapTargetSize,
- DragStartBehavior dragStartBehavior = DragStartBehavior.start,
- Color? focusColor,
- Color? hoverColor,
- bool autofocus = false,
- ValueChanged<
bool> ? onFocusChange, - EdgeInsetsGeometry? padding,
- bool? applyCupertinoTheme,
- WidgetStateProperty<
Color?> ? thumbColor, - WidgetStateProperty<
Icon?> ? thumbIcon, - WidgetStateProperty<
Color?> ? trackColor, - WidgetStateProperty<
double?> ? trackOutlineWidth, - WidgetStateProperty<
Color?> ? trackOutlineColor, - WidgetStateProperty<
Color?> ? overlayColor, - MouseCursor? mouseCursor,
- double? splashRadius,
- ReactiveFormFieldCallback<
bool> ? onChanged,
Creates a ReactiveSwitch that wraps a CupertinoSwitch if the target platform is iOS, creates a material design switch otherwise.
If a CupertinoSwitch is created, the following parameters are
ignored: activeTrackColor, inactiveThumbColor, inactiveTrackColor,
activeThumbImage, onActiveThumbImageError, inactiveThumbImage,
onInactiveImageThumbError, materialTapTargetSize.
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.
The target platform is based on the current Theme: ThemeData.platform.
For documentation about the various parameters, see the Switch.adaptive constructor.
Implementation
ReactiveSwitch.adaptive({
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,
ValueChanged<bool>? onFocusChange,
EdgeInsetsGeometry? padding,
bool? applyCupertinoTheme,
WidgetStateProperty<Color?>? thumbColor,
WidgetStateProperty<Icon?>? thumbIcon,
WidgetStateProperty<Color?>? trackColor,
WidgetStateProperty<double?>? trackOutlineWidth,
WidgetStateProperty<Color?>? trackOutlineColor,
WidgetStateProperty<Color?>? overlayColor,
MouseCursor? mouseCursor,
double? splashRadius,
ReactiveFormFieldCallback<bool>? onChanged,
}) : super(
builder: (field) {
return Switch.adaptive(
value: field.value ?? false,
activeColor: activeColor,
activeTrackColor: activeTrackColor,
inactiveThumbColor: inactiveThumbColor,
inactiveTrackColor: inactiveTrackColor,
activeThumbImage: activeThumbImage,
onActiveThumbImageError: onActiveThumbImageError,
inactiveThumbImage: inactiveThumbImage,
onInactiveThumbImageError: onInactiveThumbImageError,
materialTapTargetSize: materialTapTargetSize,
dragStartBehavior: dragStartBehavior,
focusColor: focusColor,
hoverColor: hoverColor,
thumbColor: thumbColor,
thumbIcon: thumbIcon,
trackColor: trackColor,
trackOutlineWidth: trackOutlineWidth,
trackOutlineColor: trackOutlineColor,
mouseCursor: mouseCursor,
overlayColor: overlayColor,
splashRadius: splashRadius,
autofocus: autofocus,
padding: padding,
applyCupertinoTheme: applyCupertinoTheme,
onFocusChange: onFocusChange,
focusNode: field.focusNode,
onChanged:
field.control.enabled
? (value) {
field.didChange(value);
onChanged?.call(field.control);
}
: null,
);
},
);