CupertinoSwitch constructor
- Key? key,
- required bool value,
- required ValueChanged<
bool> ? onChanged, - @Deprecated('Use activeTrackColor instead. ' 'This feature was deprecated after v3.24.0-0.2.pre.') Color? activeColor,
- @Deprecated('Use inactiveTrackColor instead. ' 'This feature was deprecated after v3.24.0-0.2.pre.') Color? trackColor,
- Color? activeTrackColor,
- Color? inactiveTrackColor,
- Color? thumbColor,
- Color? inactiveThumbColor,
- bool? applyTheme,
- Color? focusColor,
- Color? onLabelColor,
- Color? offLabelColor,
- ImageProvider<
Object> ? activeThumbImage, - ImageErrorListener? onActiveThumbImageError,
- ImageProvider<
Object> ? inactiveThumbImage, - ImageErrorListener? onInactiveThumbImageError,
- WidgetStateProperty<
Color?> ? trackOutlineColor, - WidgetStateProperty<
double?> ? trackOutlineWidth, - WidgetStateProperty<
Icon?> ? thumbIcon, - WidgetStateProperty<
MouseCursor> ? mouseCursor, - FocusNode? focusNode,
- ValueChanged<
bool> ? onFocusChange, - bool autofocus = false,
- DragStartBehavior dragStartBehavior = DragStartBehavior.start,
Creates an iOS-style switch.
The following arguments are required:
value
determines whether this switch is on or off.onChanged
is called when the user toggles the switch on or off.
The dragStartBehavior
parameter defaults to DragStartBehavior.start.
Implementation
const CupertinoSwitch({
super.key,
required this.value,
required this.onChanged,
@Deprecated(
'Use activeTrackColor instead. '
'This feature was deprecated after v3.24.0-0.2.pre.'
)
Color? activeColor,
@Deprecated(
'Use inactiveTrackColor instead. '
'This feature was deprecated after v3.24.0-0.2.pre.'
)
Color? trackColor,
Color? activeTrackColor,
Color? inactiveTrackColor,
this.thumbColor,
this.inactiveThumbColor,
this.applyTheme,
this.focusColor,
this.onLabelColor,
this.offLabelColor,
this.activeThumbImage,
this.onActiveThumbImageError,
this.inactiveThumbImage,
this.onInactiveThumbImageError,
this.trackOutlineColor,
this.trackOutlineWidth,
this.thumbIcon,
this.mouseCursor,
this.focusNode,
this.onFocusChange,
this.autofocus = false,
this.dragStartBehavior = DragStartBehavior.start,
}) : assert(activeThumbImage != null || onActiveThumbImageError == null),
assert(inactiveThumbImage != null || onInactiveThumbImageError == null),
assert(activeTrackColor == null || activeColor == null),
assert(inactiveTrackColor == null || trackColor == null),
activeTrackColor = activeTrackColor ?? activeColor,
inactiveTrackColor = inactiveTrackColor ?? trackColor;