@@ -1025,7 +1025,7 @@ class SelectionOverlay {
10251025 context: context,
10261026 below: magnifierConfiguration.shouldDisplayHandlesInMagnifier
10271027 ? null
1028- : _handles? .first ,
1028+ : _handles? .start ,
10291029 builder: (_) => builtMagnifier);
10301030 }
10311031
@@ -1333,7 +1333,7 @@ class SelectionOverlay {
13331333
13341334 /// A pair of handles. If this is non-null, there are always 2, though the
13351335 /// second is hidden when the selection is collapsed.
1336- List < OverlayEntry > ? _handles;
1336+ ({ OverlayEntry start, OverlayEntry end}) ? _handles;
13371337
13381338 /// A copy/paste toolbar.
13391339 OverlayEntry ? _toolbar;
@@ -1351,22 +1351,23 @@ class SelectionOverlay {
13511351 return ;
13521352 }
13531353
1354- _handles = < OverlayEntry > [
1355- OverlayEntry (builder: _buildStartHandle),
1356- OverlayEntry (builder: _buildEndHandle),
1357- ];
1358- Overlay .of (context, rootOverlay: true , debugRequiredFor: debugRequiredFor).insertAll (_handles! );
1354+ _handles = (
1355+ start: OverlayEntry (builder: _buildStartHandle),
1356+ end: OverlayEntry (builder: _buildEndHandle),
1357+ );
1358+ Overlay .of (context, rootOverlay: true , debugRequiredFor: debugRequiredFor)
1359+ .insertAll (< OverlayEntry > [_handles! .start, _handles! .end]);
13591360 }
13601361
13611362 /// {@template flutter.widgets.SelectionOverlay.hideHandles}
13621363 /// Destroys the handles by removing them from overlay.
13631364 /// {@endtemplate}
13641365 void hideHandles () {
13651366 if (_handles != null ) {
1366- _handles! [ 0 ] .remove ();
1367- _handles! [ 0 ] .dispose ();
1368- _handles! [ 1 ] .remove ();
1369- _handles! [ 1 ] .dispose ();
1367+ _handles! .start .remove ();
1368+ _handles! .start .dispose ();
1369+ _handles! .end .remove ();
1370+ _handles! .end .dispose ();
13701371 _handles = null ;
13711372 }
13721373 }
@@ -1444,8 +1445,8 @@ class SelectionOverlay {
14441445 SchedulerBinding .instance.addPostFrameCallback ((Duration duration) {
14451446 _buildScheduled = false ;
14461447 if (_handles != null ) {
1447- _handles! [ 0 ] .markNeedsBuild ();
1448- _handles! [ 1 ] .markNeedsBuild ();
1448+ _handles! .start .markNeedsBuild ();
1449+ _handles! .end .markNeedsBuild ();
14491450 }
14501451 _toolbar? .markNeedsBuild ();
14511452 if (_contextMenuController.isShown) {
@@ -1456,8 +1457,8 @@ class SelectionOverlay {
14561457 });
14571458 } else {
14581459 if (_handles != null ) {
1459- _handles! [ 0 ] .markNeedsBuild ();
1460- _handles! [ 1 ] .markNeedsBuild ();
1460+ _handles! .start .markNeedsBuild ();
1461+ _handles! .end .markNeedsBuild ();
14611462 }
14621463 _toolbar? .markNeedsBuild ();
14631464 if (_contextMenuController.isShown) {
@@ -1474,10 +1475,10 @@ class SelectionOverlay {
14741475 void hide () {
14751476 _magnifierController.hide ();
14761477 if (_handles != null ) {
1477- _handles! [ 0 ] .remove ();
1478- _handles! [ 0 ] .dispose ();
1479- _handles! [ 1 ] .remove ();
1480- _handles! [ 1 ] .dispose ();
1478+ _handles! .start .remove ();
1479+ _handles! .start .dispose ();
1480+ _handles! .end .remove ();
1481+ _handles! .end .dispose ();
14811482 _handles = null ;
14821483 }
14831484 if (_toolbar != null || _contextMenuController.isShown || _spellCheckToolbarController.isShown) {
0 commit comments