Unverified Commit 7b0293d6 authored by fzyzcjy's avatar fzyzcjy Committed by GitHub

Tiny improve code style by using records instead of lists (#135886)

parent bf1cdb15
...@@ -1025,7 +1025,7 @@ class SelectionOverlay { ...@@ -1025,7 +1025,7 @@ class SelectionOverlay {
context: context, context: context,
below: magnifierConfiguration.shouldDisplayHandlesInMagnifier below: magnifierConfiguration.shouldDisplayHandlesInMagnifier
? null ? null
: _handles?.first, : _handles?.start,
builder: (_) => builtMagnifier); builder: (_) => builtMagnifier);
} }
...@@ -1333,7 +1333,7 @@ class SelectionOverlay { ...@@ -1333,7 +1333,7 @@ class SelectionOverlay {
/// A pair of handles. If this is non-null, there are always 2, though the /// A pair of handles. If this is non-null, there are always 2, though the
/// second is hidden when the selection is collapsed. /// second is hidden when the selection is collapsed.
List<OverlayEntry>? _handles; ({OverlayEntry start, OverlayEntry end})? _handles;
/// A copy/paste toolbar. /// A copy/paste toolbar.
OverlayEntry? _toolbar; OverlayEntry? _toolbar;
...@@ -1351,11 +1351,12 @@ class SelectionOverlay { ...@@ -1351,11 +1351,12 @@ class SelectionOverlay {
return; return;
} }
_handles = <OverlayEntry>[ _handles = (
OverlayEntry(builder: _buildStartHandle), start: OverlayEntry(builder: _buildStartHandle),
OverlayEntry(builder: _buildEndHandle), end: OverlayEntry(builder: _buildEndHandle),
]; );
Overlay.of(context, rootOverlay: true, debugRequiredFor: debugRequiredFor).insertAll(_handles!); Overlay.of(context, rootOverlay: true, debugRequiredFor: debugRequiredFor)
.insertAll(<OverlayEntry>[_handles!.start, _handles!.end]);
} }
/// {@template flutter.widgets.SelectionOverlay.hideHandles} /// {@template flutter.widgets.SelectionOverlay.hideHandles}
...@@ -1363,10 +1364,10 @@ class SelectionOverlay { ...@@ -1363,10 +1364,10 @@ class SelectionOverlay {
/// {@endtemplate} /// {@endtemplate}
void hideHandles() { void hideHandles() {
if (_handles != null) { if (_handles != null) {
_handles![0].remove(); _handles!.start.remove();
_handles![0].dispose(); _handles!.start.dispose();
_handles![1].remove(); _handles!.end.remove();
_handles![1].dispose(); _handles!.end.dispose();
_handles = null; _handles = null;
} }
} }
...@@ -1444,8 +1445,8 @@ class SelectionOverlay { ...@@ -1444,8 +1445,8 @@ class SelectionOverlay {
SchedulerBinding.instance.addPostFrameCallback((Duration duration) { SchedulerBinding.instance.addPostFrameCallback((Duration duration) {
_buildScheduled = false; _buildScheduled = false;
if (_handles != null) { if (_handles != null) {
_handles![0].markNeedsBuild(); _handles!.start.markNeedsBuild();
_handles![1].markNeedsBuild(); _handles!.end.markNeedsBuild();
} }
_toolbar?.markNeedsBuild(); _toolbar?.markNeedsBuild();
if (_contextMenuController.isShown) { if (_contextMenuController.isShown) {
...@@ -1456,8 +1457,8 @@ class SelectionOverlay { ...@@ -1456,8 +1457,8 @@ class SelectionOverlay {
}); });
} else { } else {
if (_handles != null) { if (_handles != null) {
_handles![0].markNeedsBuild(); _handles!.start.markNeedsBuild();
_handles![1].markNeedsBuild(); _handles!.end.markNeedsBuild();
} }
_toolbar?.markNeedsBuild(); _toolbar?.markNeedsBuild();
if (_contextMenuController.isShown) { if (_contextMenuController.isShown) {
...@@ -1474,10 +1475,10 @@ class SelectionOverlay { ...@@ -1474,10 +1475,10 @@ class SelectionOverlay {
void hide() { void hide() {
_magnifierController.hide(); _magnifierController.hide();
if (_handles != null) { if (_handles != null) {
_handles![0].remove(); _handles!.start.remove();
_handles![0].dispose(); _handles!.start.dispose();
_handles![1].remove(); _handles!.end.remove();
_handles![1].dispose(); _handles!.end.dispose();
_handles = null; _handles = null;
} }
if (_toolbar != null || _contextMenuController.isShown || _spellCheckToolbarController.isShown) { if (_toolbar != null || _contextMenuController.isShown || _spellCheckToolbarController.isShown) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment