MouseTracker class

Maintains the relationship between mouse devices and MouseTrackerAnnotations, and notifies interested callbacks of the changes thereof.

This class is a ChangeNotifier that notifies its listeners if the value of mouseIsConnected changes.

An instance of MouseTracker is owned by the global singleton of RendererBinding.


The state of MouseTracker consists of two parts:

  • The mouse devices that are connected.
  • In which annotations each device is contained.

The states remain stable most of the time, and are only changed at the following moments:

  • An eligible PointerEvent has been observed, e.g. a device is added, removed, or moved. In this case, the state related to this device will be immediately updated.
  • A frame has been painted. In this case, a callback will be scheduled for the upcoming post-frame phase to update all devices.


MouseTracker(PointerRouter _router, MouseDetectorAnnotationFinder annotationFinder)
Creates a mouse tracker to keep track of mouse locations. [...]


annotationFinder MouseDetectorAnnotationFinder
Find annotations at a given offset in global logical coordinate space in visual order from front to back. [...]
mouseIsConnected bool
Whether or not a mouse is connected and has produced events.
hashCode int
The hash code for this object. [...]
read-only, inherited
hasListeners bool
Whether any listeners are currently registered.
@protected, read-only, inherited
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited


dispose() → void
Discards any resources used by the object. After this is called, the object is not in a usable state and should be discarded (calls to addListener and removeListener will throw after the object is disposed). [...]
schedulePostFrameCheck() → void
Mark all devices as dirty, and schedule a callback that is executed in the upcoming post-frame phase to check their updates. [...]
addListener(VoidCallback listener) → void
Register a closure to be called when the object changes.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
notifyListeners() → void
Call all the registered listeners.
@protected, @visibleForTesting, inherited
removeListener(VoidCallback listener) → void
Remove a previously registered closure from the list of closures that are notified when the object changes.
toString() String
Returns a string representation of this object.


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