FormeSwitch constructor
FormeSwitch({
- Key? key,
- String? name,
- bool initialValue = false,
- FormeAsyncValidator<
bool> ? asyncValidator, - Duration? asyncValidatorDebounce,
- AutovalidateMode? autovalidateMode,
- bool enabled = true,
- FocusNode? focusNode,
- FormeFieldInitialized<
bool> ? onInitialized, - FormeFieldSetter<
bool> ? onSaved, - FormeFieldStatusChanged<
bool> ? onStatusChanged, - int? order,
- bool quietlyValidate = false,
- bool readOnly = false,
- bool requestFocusOnUserInteraction = true,
- FormeFieldValidationFilter<
bool> ? validationFilter, - FormeValidator<
bool> ? validator, - FormeFieldDecorator<
bool> ? decorator, - Color? activeColor,
- Color? activeTrackColor,
- Color? inactiveThumbColor,
- Color? inactiveTrackColor,
- ImageProvider<
Object> ? activeThumbImage, - ImageProvider<
Object> ? inactiveThumbImage, - MaterialStateProperty<
Color?> ? thumbColor, - MaterialStateProperty<
Color?> ? trackColor, - DragStartBehavior? dragStartBehavior,
- MaterialTapTargetSize? materialTapTargetSize,
- Color? focusColor,
- Color? hoverColor,
- MaterialStateProperty<
Color?> ? overlayColor, - double? splashRadius,
- ImageErrorListener? onActiveThumbImageError,
- ImageErrorListener? onInactiveThumbImageError,
- bool autofocus = false,
- MaterialStateProperty<
Icon?> ? thumbIcon, - MouseCursor? mouseCursor,
Implementation
FormeSwitch({
super.key,
super.name,
super.initialValue = false,
super.asyncValidator,
super.asyncValidatorDebounce,
super.autovalidateMode,
super.enabled = true,
super.focusNode,
super.onInitialized,
super.onSaved,
super.onStatusChanged,
super.order,
super.quietlyValidate = false,
super.readOnly = false,
super.requestFocusOnUserInteraction = true,
super.validationFilter,
super.validator,
super.decorator,
this.activeColor,
this.activeTrackColor,
this.inactiveThumbColor,
this.inactiveTrackColor,
this.activeThumbImage,
this.inactiveThumbImage,
this.thumbColor,
this.trackColor,
this.dragStartBehavior,
this.materialTapTargetSize,
this.focusColor,
this.hoverColor,
this.overlayColor,
this.splashRadius,
this.onActiveThumbImageError,
this.onInactiveThumbImageError,
this.autofocus = false,
this.thumbIcon,
this.mouseCursor,
}) : super.allFields(
builder: (state) {
final bool readOnly = state.readOnly;
final bool value = state.value;
return Switch(
mouseCursor: mouseCursor,
thumbIcon: thumbIcon,
value: value,
onChanged: readOnly
? null
: (_) {
state.didChange(!value);
state.requestFocusOnUserInteraction();
},
activeColor: activeColor,
activeTrackColor: activeTrackColor,
inactiveThumbColor: inactiveThumbColor,
inactiveTrackColor: inactiveTrackColor,
activeThumbImage: activeThumbImage,
inactiveThumbImage: inactiveThumbImage,
materialTapTargetSize: materialTapTargetSize,
thumbColor: thumbColor,
trackColor: trackColor,
dragStartBehavior: dragStartBehavior ?? DragStartBehavior.start,
focusColor: focusColor,
hoverColor: hoverColor,
overlayColor: overlayColor,
splashRadius: splashRadius,
onActiveThumbImageError: onActiveThumbImageError,
onInactiveThumbImageError: onInactiveThumbImageError,
focusNode: state.focusNode,
autofocus: autofocus,
);
},
);