thumbIcon property
The icon to use on the thumb of this switch
Resolved in the following states:
This example resolves the thumbIcon based on the current
WidgetState of the Switch, providing a different Icon when it is
WidgetState.disabled.
Switch(
value: _value,
// If `onChanged` is null, this switch is disabled.
// If `onChanged` is not null, this switch is enabled.
onChanged: _nullableOnChanged,
thumbIcon: WidgetStateProperty.resolveWith<Icon?>((
Set<WidgetState> states,
) {
if (states.contains(WidgetState.disabled)) {
return const Icon(Icons.close);
}
return null; // All other states will use the default thumbIcon.
}),
)
It is overridden by Switch.thumbIcon.
Implementation
final WidgetStateProperty<Icon?>? thumbIcon;