Fix Magnifier crash (#111303)
This commit is contained in:
committed by
GitHub
parent
52af1a51e0
commit
8f9a519519
@@ -853,7 +853,7 @@ class SelectionOverlay {
|
||||
_magnifierOverlayInfoBearer,
|
||||
);
|
||||
|
||||
if (builtMagnifier == null || _handles == null) {
|
||||
if (builtMagnifier == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -861,7 +861,7 @@ class SelectionOverlay {
|
||||
context: context,
|
||||
below: magnifierConfiguration.shouldDisplayHandlesInMagnifier
|
||||
? null
|
||||
: _handles!.first,
|
||||
: _handles?.first,
|
||||
builder: (_) => builtMagnifier);
|
||||
}
|
||||
|
||||
|
||||
@@ -1030,6 +1030,7 @@ void main() {
|
||||
ValueChanged<DragEndDetails>? onEndDragEnd,
|
||||
VoidCallback? onSelectionHandleTapped,
|
||||
TextSelectionControls? selectionControls,
|
||||
TextMagnifierConfiguration? magnifierConfiguration,
|
||||
}) async {
|
||||
final UniqueKey column = UniqueKey();
|
||||
final LayerLink startHandleLayerLink = LayerLink();
|
||||
@@ -1075,6 +1076,7 @@ void main() {
|
||||
selectionControls: selectionControls,
|
||||
selectionEndpoints: const <TextSelectionPoint>[],
|
||||
toolbarLayerLink: toolbarLayerLink,
|
||||
magnifierConfiguration: magnifierConfiguration ?? TextMagnifierConfiguration.disabled,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1279,6 +1281,35 @@ void main() {
|
||||
await tester.pump(const Duration(milliseconds: 20));
|
||||
expect(endDragEndDetails, isNotNull);
|
||||
});
|
||||
|
||||
testWidgets('can show magnifier when no handles exist', (WidgetTester tester) async {
|
||||
final GlobalKey magnifierKey = GlobalKey();
|
||||
final SelectionOverlay selectionOverlay = await pumpApp(
|
||||
tester,
|
||||
magnifierConfiguration: TextMagnifierConfiguration(
|
||||
shouldDisplayHandlesInMagnifier: false,
|
||||
magnifierBuilder: (BuildContext context, MagnifierController controller, ValueNotifier<MagnifierOverlayInfoBearer>? notifier) {
|
||||
return SizedBox.shrink(
|
||||
key: magnifierKey,
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.byKey(magnifierKey), findsNothing);
|
||||
|
||||
final MagnifierOverlayInfoBearer info = MagnifierOverlayInfoBearer(
|
||||
globalGesturePosition: Offset.zero,
|
||||
caretRect: Offset.zero & const Size(5.0, 20.0),
|
||||
fieldBounds: Offset.zero & const Size(200.0, 50.0),
|
||||
currentLineBoundaries: Offset.zero & const Size(200.0, 50.0),
|
||||
);
|
||||
selectionOverlay.showMagnifier(info);
|
||||
await tester.pump();
|
||||
|
||||
expect(tester.takeException(), isNull);
|
||||
expect(find.byKey(magnifierKey), findsOneWidget);
|
||||
});
|
||||
});
|
||||
|
||||
group('ClipboardStatusNotifier', () {
|
||||
|
||||
Reference in New Issue
Block a user