mouseCursor property
final
The cursor for a mouse pointer when it enters or is hovering over the widget.
Resolved in the following states:
This example resolves the mouseCursor based on the current
WidgetState of the CupertinoSwitch, providing a different mouseCursor when it is
WidgetState.disabled.
link
CupertinoSwitch(
value: true,
onChanged: (bool value) { },
mouseCursor: WidgetStateProperty.resolveWith<MouseCursor>((Set<WidgetState> states) {
if (states.contains(WidgetState.disabled)) {
return SystemMouseCursors.click;
}
return SystemMouseCursors.basic; // All other states will use the default mouseCursor.
}),
)
If null, then MouseCursor.defer is used when the switch is disabled. When the switch is enabled, SystemMouseCursors.click is used on Web, and MouseCursor.defer is used on other platforms.
See also:
- WidgetStateMouseCursor, a MouseCursor that implements
WidgetStateProperty
which is used in APIs that need to accept either a MouseCursor or a WidgetStateProperty.
Implementation
final WidgetStateProperty<MouseCursor>? mouseCursor;