5
5
/// @docImport 'binding.dart';
6
6
library ;
7
7
8
- import 'dart:collection' show LinkedHashMap;
9
8
import 'dart:ui' ;
10
9
11
10
import 'package:flutter/foundation.dart' ;
@@ -27,16 +26,13 @@ class _MouseState {
27
26
_MouseState ({required PointerEvent initialEvent}) : _latestEvent = initialEvent;
28
27
29
28
// The list of annotations that contains this device.
30
- //
31
- // It uses [LinkedHashMap] to keep the insertion order.
32
- LinkedHashMap <MouseTrackerAnnotation , Matrix4 > get annotations => _annotations;
33
- LinkedHashMap <MouseTrackerAnnotation , Matrix4 > _annotations =
34
- LinkedHashMap <MouseTrackerAnnotation , Matrix4 >();
29
+ Map <MouseTrackerAnnotation , Matrix4 > get annotations => _annotations;
30
+ Map <MouseTrackerAnnotation , Matrix4 > _annotations = < MouseTrackerAnnotation , Matrix4 > {};
35
31
36
- LinkedHashMap <MouseTrackerAnnotation , Matrix4 > replaceAnnotations (
37
- LinkedHashMap <MouseTrackerAnnotation , Matrix4 > value,
32
+ Map <MouseTrackerAnnotation , Matrix4 > replaceAnnotations (
33
+ Map <MouseTrackerAnnotation , Matrix4 > value,
38
34
) {
39
- final LinkedHashMap <MouseTrackerAnnotation , Matrix4 > previous = _annotations;
35
+ final Map <MouseTrackerAnnotation , Matrix4 > previous = _annotations;
40
36
_annotations = value;
41
37
return previous;
42
38
}
@@ -93,12 +89,12 @@ class _MouseTrackerUpdateDetails with Diagnosticable {
93
89
/// The annotations that the device is hovering before the update.
94
90
///
95
91
/// It is never null.
96
- final LinkedHashMap <MouseTrackerAnnotation , Matrix4 > lastAnnotations;
92
+ final Map <MouseTrackerAnnotation , Matrix4 > lastAnnotations;
97
93
98
94
/// The annotations that the device is hovering after the update.
99
95
///
100
96
/// It is never null.
101
- final LinkedHashMap <MouseTrackerAnnotation , Matrix4 > nextAnnotations;
97
+ final Map <MouseTrackerAnnotation , Matrix4 > nextAnnotations;
102
98
103
99
/// The last event that the device observed before the update.
104
100
///
@@ -232,11 +228,8 @@ class MouseTracker extends ChangeNotifier {
232
228
lastEvent.position != event.position;
233
229
}
234
230
235
- LinkedHashMap <MouseTrackerAnnotation , Matrix4 > _hitTestInViewResultToAnnotations (
236
- HitTestResult result,
237
- ) {
238
- final LinkedHashMap <MouseTrackerAnnotation , Matrix4 > annotations =
239
- LinkedHashMap <MouseTrackerAnnotation , Matrix4 >();
231
+ Map <MouseTrackerAnnotation , Matrix4 > _hitTestInViewResultToAnnotations (HitTestResult result) {
232
+ final Map <MouseTrackerAnnotation , Matrix4 > annotations = < MouseTrackerAnnotation , Matrix4 > {};
240
233
for (final HitTestEntry entry in result.path) {
241
234
final Object target = entry.target;
242
235
if (target is MouseTrackerAnnotation ) {
@@ -251,12 +244,12 @@ class MouseTracker extends ChangeNotifier {
251
244
//
252
245
// If the device is not connected or not a mouse, an empty map is returned
253
246
// without calling `hitTest`.
254
- LinkedHashMap <MouseTrackerAnnotation , Matrix4 > _findAnnotations (_MouseState state) {
247
+ Map <MouseTrackerAnnotation , Matrix4 > _findAnnotations (_MouseState state) {
255
248
final Offset globalPosition = state.latestEvent.position;
256
249
final int device = state.device;
257
250
final int viewId = state.latestEvent.viewId;
258
251
if (! _mouseStates.containsKey (device)) {
259
- return LinkedHashMap <MouseTrackerAnnotation , Matrix4 >() ;
252
+ return < MouseTrackerAnnotation , Matrix4 > {} ;
260
253
}
261
254
262
255
return _hitTestInViewResultToAnnotations (_hitTestInView (globalPosition, viewId));
@@ -341,12 +334,13 @@ class MouseTracker extends ChangeNotifier {
341
334
final _MouseState targetState = _mouseStates[device] ?? existingState! ;
342
335
343
336
final PointerEvent lastEvent = targetState.replaceLatestEvent (event);
344
- final LinkedHashMap <MouseTrackerAnnotation , Matrix4 > nextAnnotations =
337
+ final Map <MouseTrackerAnnotation , Matrix4 > nextAnnotations =
345
338
event is PointerRemovedEvent
346
- ? LinkedHashMap <MouseTrackerAnnotation , Matrix4 >()
339
+ ? < MouseTrackerAnnotation , Matrix4 > {}
347
340
: _hitTestInViewResultToAnnotations (result);
348
- final LinkedHashMap <MouseTrackerAnnotation , Matrix4 > lastAnnotations = targetState
349
- .replaceAnnotations (nextAnnotations);
341
+ final Map <MouseTrackerAnnotation , Matrix4 > lastAnnotations = targetState.replaceAnnotations (
342
+ nextAnnotations,
343
+ );
350
344
351
345
_handleDeviceUpdate (
352
346
_MouseTrackerUpdateDetails .byPointerEvent (
@@ -374,11 +368,10 @@ class MouseTracker extends ChangeNotifier {
374
368
_deviceUpdatePhase (() {
375
369
for (final _MouseState dirtyState in _mouseStates.values) {
376
370
final PointerEvent lastEvent = dirtyState.latestEvent;
377
- final LinkedHashMap <MouseTrackerAnnotation , Matrix4 > nextAnnotations = _findAnnotations (
378
- dirtyState,
371
+ final Map <MouseTrackerAnnotation , Matrix4 > nextAnnotations = _findAnnotations (dirtyState);
372
+ final Map <MouseTrackerAnnotation , Matrix4 > lastAnnotations = dirtyState.replaceAnnotations (
373
+ nextAnnotations,
379
374
);
380
- final LinkedHashMap <MouseTrackerAnnotation , Matrix4 > lastAnnotations = dirtyState
381
- .replaceAnnotations (nextAnnotations);
382
375
383
376
_handleDeviceUpdate (
384
377
_MouseTrackerUpdateDetails .byNewFrame (
@@ -407,8 +400,8 @@ class MouseTracker extends ChangeNotifier {
407
400
static void _handleDeviceUpdateMouseEvents (_MouseTrackerUpdateDetails details) {
408
401
final PointerEvent latestEvent = details.latestEvent;
409
402
410
- final LinkedHashMap <MouseTrackerAnnotation , Matrix4 > lastAnnotations = details.lastAnnotations;
411
- final LinkedHashMap <MouseTrackerAnnotation , Matrix4 > nextAnnotations = details.nextAnnotations;
403
+ final Map <MouseTrackerAnnotation , Matrix4 > lastAnnotations = details.lastAnnotations;
404
+ final Map <MouseTrackerAnnotation , Matrix4 > nextAnnotations = details.nextAnnotations;
412
405
413
406
// Order is important for mouse event callbacks. The
414
407
// `_hitTestInViewResultToAnnotations` returns annotations in the visual order
0 commit comments