Tiny improve code style by using records instead of lists (#135886)
This commit is contained in:
parent
bf1cdb1596
commit
7b0293d663
@ -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 {
|
|||||||
|
|
||||||
/// 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 {
|
|||||||
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 {
|
|||||||
/// {@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 {
|
|||||||
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 {
|
|||||||
});
|
});
|
||||||
} 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 {
|
|||||||
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) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user