diff --git a/packages/flutter/lib/src/widgets/text_selection.dart b/packages/flutter/lib/src/widgets/text_selection.dart index dd23425ca8de..f33ba25ea9a2 100644 --- a/packages/flutter/lib/src/widgets/text_selection.dart +++ b/packages/flutter/lib/src/widgets/text_selection.dart @@ -2850,6 +2850,10 @@ class TextSelectionGestureDetectorBuilder { final bool isShiftPressed = _containsShift(details.keysPressedOnDown); _dragBeganOnPreviousSelection = null; + if (_shouldShowSelectionToolbar && _TextSelectionGestureDetectorState._getEffectiveConsecutiveTapCount(details.consecutiveTapCount) == 2) { + editableText.showToolbar(); + } + if (isShiftPressed) { _dragStartSelection = null; } diff --git a/packages/flutter/test/cupertino/text_field_test.dart b/packages/flutter/test/cupertino/text_field_test.dart index a5c726fdf1ed..db4e297df874 100644 --- a/packages/flutter/test/cupertino/text_field_test.dart +++ b/packages/flutter/test/cupertino/text_field_test.dart @@ -2245,8 +2245,15 @@ void main() { await gesture.moveTo(hPos); await tester.pumpAndSettle(); + // Toolbar should be hidden during a drag. + expect(find.byType(CupertinoButton), findsNothing); expect(controller.selection.baseOffset, testValue.indexOf('d')); expect(controller.selection.extentOffset, testValue.indexOf('i') + 1); + + // Toolbar should re-appear after a drag. + await gesture.up(); + await tester.pump(); + expect(find.byType(CupertinoButton), isContextMenuProvidedByPlatform ? findsNothing : findsNWidgets(4)); }, ); diff --git a/packages/flutter/test/material/text_field_test.dart b/packages/flutter/test/material/text_field_test.dart index 9106c84d55d1..3fd079168ab2 100644 --- a/packages/flutter/test/material/text_field_test.dart +++ b/packages/flutter/test/material/text_field_test.dart @@ -9396,8 +9396,15 @@ void main() { await gesture.moveTo(hPos); await tester.pumpAndSettle(); + // Toolbar should be hidden during a drag. + expect(find.byType(TextButton), findsNothing); expect(controller.selection.baseOffset, testValue.indexOf('d')); expect(controller.selection.extentOffset, testValue.indexOf('i') + 1); + + // Toolbar should re-appear after a drag. + await gesture.up(); + await tester.pump(); + expect(find.byType(TextButton), isContextMenuProvidedByPlatform ? findsNothing : findsNWidgets(4)); }, );