WidgetStateMouseCursor class abstract

Defines a MouseCursor whose value depends on a set of WidgetStates which represent the interactive state of a component.

This kind of MouseCursor is useful when the set of interactive actions a widget supports varies with its state. For example, a mouse pointer hovering over a disabled ListTile should not display SystemMouseCursors.click, since a disabled list tile doesn't respond to mouse clicks. ListTile's default mouse cursor is a WidgetStateMouseCursor.clickable, which resolves to SystemMouseCursors.basic when the button is disabled.

This class should only be used for parameters that document their support for WidgetStateMouseCursor.

A WidgetStateMouseCursor can be created in one of the following ways:

  1. Create a subclass of WidgetStateMouseCursor and implement the abstract resolve method.
  2. Use WidgetStateMouseCursor.resolveWith and pass in a callback that will be used to resolve the color in the given states.
  3. Use WidgetStateMouseCursor.fromMap to assign a value using a WidgetStateMap.

This example defines a mouse cursor that resolves to SystemMouseCursors.forbidden when its widget is disabled.
link

To create a local project with this code sample, run:
flutter create --sample=widgets.WidgetStateMouseCursor.1 mysample

See also:

Inheritance
Implemented types

Constructors

WidgetStateMouseCursor()
Abstract const constructor. This constructor enables subclasses to provide const constructors so that they can be used in const expressions.
const
WidgetStateMouseCursor.fromMap(WidgetStateMap<MouseCursor> map)
Creates a WidgetStateMouseCursor from a WidgetStateMap.
const
factory
WidgetStateMouseCursor.resolveWith(WidgetPropertyResolver<MouseCursor> callback, {String debugDescription})
Creates a WidgetStateMouseCursor using a WidgetPropertyResolver callback.
const
factory

Properties

debugDescription String
A very short description of the mouse cursor.
no setterinherited
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

createSession(int device) MouseCursorSession
Associate a pointing device to this cursor.
override
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
resolve(Set<WidgetState> states) MouseCursor
Returns a MouseCursor that's to be used when a component is in the specified state.
override
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringShort() String
A brief description of this object, usually just the runtimeType and the hashCode.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Constants

clickable → const WidgetStateMouseCursor
A mouse cursor for clickable widgets, which resolves differently when the widget is disabled.
textable → const WidgetStateMouseCursor
A mouse cursor for widgets related to text, which resolves differently when the widget is disabled.