MaterialStateMouseCursor class

Defines a MouseCursor whose value depends on a set of MaterialStates 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 FlatButton should not display, since the button is not clickable. To solve this, you can use MaterialStateMouseCursor to assign a different cursor (such as SystemMouseCursors.basic) when the FlatButton is disabled.

To use a MaterialStateMouseCursor, you should create a subclass of MaterialStateMouseCursor and implement the abstract resolve method.

In this next example, we see how you can create a MaterialStateMouseCursor by extending the abstract class and overriding the resolve method.
class ButtonCursor extends MaterialStateMouseCursor {
  const ButtonCursor();

  MouseCursor resolve(Set<MaterialState> states) {
    if (states.contains(MaterialState.disabled)) {
      return SystemMouseCursors.forbidden;

  String get debugDescription => 'ButtonCursor()';

class MyFlatButton extends StatelessWidget {
  Widget build(BuildContext context) {
    return FlatButton(
      child: Text('FlatButton'),
      onPressed: () {},
      mouseCursor: const ButtonCursor(),

This should only be used as parameters when they are documented to take MaterialStateMouseCursor, otherwise only the default state will be used.

This class also predefines several kinds of material state mouse cursors.

See also:

Implemented types


Creates a MaterialStateMouseCursor.


debugDescription String
A very short description of the mouse cursor. [...]
read-only, inherited
hashCode int
The hash code for this object. [...]
read-only, inherited
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited


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


operator ==(Object other) bool
The equality operator. [...]


clickable → const MaterialStateMouseCursor
A mouse cursor for clickable material widgets, which resolves differently when the widget is disabled. [...]
_EnabledAndDisabledMouseCursor(enabledCursor:, disabledCursor: SystemMouseCursors.basic, name: 'clickable')
textable → const MaterialStateMouseCursor
A mouse cursor for material widgets related to text, which resolves differently when the widget is disabled. [...]
_EnabledAndDisabledMouseCursor(enabledCursor: SystemMouseCursors.text, disabledCursor: SystemMouseCursors.basic, name: 'textable')