updateAllDevices method Null safety

void updateAllDevices(
  1. MouseDetectorAnnotationFinder hitTest
)

Trigger a device update for all detected devices.

The updateAllDevices is typically called during the post frame phase, indicating a frame has passed and all objects have potentially moved. The hitTest is a function that acquires the hit test result at a given position, and must not be empty.

For each connected device, the updateAllDevices will make a hit test on the device's last seen position, and check if necessary changes need to be made.

Implementation

void updateAllDevices(MouseDetectorAnnotationFinder hitTest) {
  _deviceUpdatePhase(() {
    for (final _MouseState dirtyState in _mouseStates.values) {
      final PointerEvent lastEvent = dirtyState.latestEvent;
      final LinkedHashMap<MouseTrackerAnnotation, Matrix4> nextAnnotations = _findAnnotations(dirtyState, hitTest);
      final LinkedHashMap<MouseTrackerAnnotation, Matrix4> lastAnnotations = dirtyState.replaceAnnotations(nextAnnotations);

      _handleDeviceUpdate(_MouseTrackerUpdateDetails.byNewFrame(
        lastAnnotations: lastAnnotations,
        nextAnnotations: nextAnnotations,
        previousEvent: lastEvent,
      ));
    }
  });
}