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,
- MaterialStateProperty<
Color?> ? thumbColor, - MaterialStateProperty<
Color?> ? trackColor, - MaterialStateProperty<
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({
Key? key,
String? formControlName,
FormControl<bool>? formControl,
FocusNode? 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,
MaterialStateProperty<Color?>? thumbColor,
MaterialStateProperty<Color?>? trackColor,
MaterialStateProperty<Color?>? overlayColor,
MouseCursor? mouseCursor,
double? splashRadius,
ReactiveFormFieldCallback<bool>? onChanged,
}) : super(
key: key,
formControl: formControl,
formControlName: formControlName,
focusNode: focusNode,
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,
trackColor: trackColor,
mouseCursor: mouseCursor,
overlayColor: overlayColor,
splashRadius: splashRadius,
autofocus: autofocus,
focusNode: field.focusNode,
onChanged: field.control.enabled
? (value) {
field.didChange(value);
onChanged?.call(field.control);
}
: null,
);
},
);