NmInputModeController class

Tracks the current input mode based on pointer events.

Use this to adapt UI based on whether user is using touch, trackpad, or mouse. For example, show hover states only for pointer devices.

Example:

final inputMode = NmInputModeController();

Listener(
  onPointerDown: (e) => inputMode.updateFromPointerEvent(e),
  child: Builder(
    builder: (context) {
      if (inputMode.supportsHover) {
        return HoverableWidget();
      }
      return TouchWidget();
    },
  ),
)
Inheritance

Constructors

NmInputModeController()

Properties

currentMode → NmInputMode
The current input mode.
no setter
hashCode → int
The hash code for this object.
no setterinherited
hasListeners → bool
Whether any listeners are currently registered.
no setterinherited
isPointer → bool
Whether current mode is a pointer device (mouse or trackpad).
no setter
isTouch → bool
Whether current mode is touch.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
supportsHover → bool
Whether current mode supports hover states.
no setter
supportsMultiTouch → bool
Whether current mode supports multi-touch.
no setter

Methods

addListener(VoidCallback listener) → void
Register a closure to be called when the object changes.
inherited
dispose() → void
Discards any resources used by the object.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyListeners() → void
Call all the registered listeners.
inherited
removeListener(VoidCallback listener) → void
Remove a previously registered closure from the list of closures that are notified when the object changes.
inherited
setKeyboardMode() → void
Set mode to keyboard (e.g., when Tab key is pressed).
toString() → String
A string representation of this object.
inherited
updateFromPointerEvent(PointerEvent event) → void
Update the input mode based on a pointer event.

Operators

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