Skip to content

TextField crashes on two-finger selection gesture #168578

@monkeyswarm

Description

@monkeyswarm

Steps to reproduce

  1. Have a TextField. Enter text into the text field
  2. Make a selection
  3. Move the two edit handles independently with two fingers, then release

Exception:

══╡ EXCEPTION CAUGHT BY GESTURE ╞═══════════════════════════════════════════════════════════════════
The following assertion was thrown while handling a gesture:
'package:flutter/src/widgets/text_selection.dart': Failed assertion: line 759 pos 12:
'_dragStartSelection != null': is not true.

Either the assertion indicates an error in the framework itself, or we should provide substantially
more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
  https://github.com/flutter/flutter/issues/new?template=02_bug.yml

When the exception was thrown, this was the stack:
#2      TextSelectionOverlay._handleSelectionEndHandleDragUpdate (package:flutter/src/widgets/text_selection.dart:759:12)
#3      SelectionOverlay._handleEndHandleDragUpdate (package:flutter/src/widgets/text_selection.dart:1270:28)
#4      DragGestureRecognizer._checkUpdate.<anonymous closure> (package:flutter/src/gestures/monodrag.dart:868:55)
#5      GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:345:24)
#6      DragGestureRecognizer._checkUpdate (package:flutter/src/gestures/monodrag.dart:868:7)
#7      DragGestureRecognizer.handleEvent (package:flutter/src/gestures/monodrag.dart:714:11)
#8      PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:97:12)
#9      PointerRouter._dispatchEventToRoutes.<anonymous closure> (package:flutter/src/gestures/pointer_router.dart:143:9)
#10     _LinkedHashMapMixin.forEach (dart:_compact_hash:764:13)
#11     PointerRouter._dispatchEventToRoutes (package:flutter/src/gestures/pointer_router.dart:141:18)
#12     PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:131:7)
#13     GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:530:19)
#14     GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:499:22)
#15     RendererBinding.dispatchEvent (package:flutter/src/rendering/binding.dart:473:11)
#16     GestureBinding._handlePointerEventImmediately (package:flutter/src/gestures/binding.dart:437:7)
#17     GestureBinding.handlePointerEvent (package:flutter/src/gestures/binding.dart:394:5)
#18     GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:341:7)
#19     GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:308:9)
#20     _invoke1 (dart:ui/hooks.dart:347:13)
#21     PlatformDispatcher._dispatchPointerDataPacket (dart:ui/platform_dispatcher.dart:467:7)
#22     _dispatchPointerDataPacket (dart:ui/hooks.dart:282:31)
(elided 2 frames from class _AssertionError)

Handler: "onUpdate"
Recognizer:
  PanGestureRecognizer#8943a
════════════════════════════════════════════════════════════════════════════════════════════════════

Observed on Android and iOS.

Expected results

Selection updates without exception

Actual results

Crash, seen above

Code sample

Code sample
Widget build(BuildContext context) {
    return Scaffold(
      body: Center(child: TextField()),
    );
  }

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
[✓] Flutter (Channel google3, on macOS 14.7.5 23H527 darwin-arm64 (Rosetta), locale en-US) [2.6s]
    • Framework revision b9e982614b (14 days ago), 2025-04-24T00:00:00.000
    • Engine revision b9e982614b
    • Dart version 88e2c816be

Rest of output contains proprietary information

Metadata

Metadata

Labels

P1High-priority issues at the top of the work lista: error messageError messages from the Flutter frameworka: text inputEntering text in a text field or keyboard related problemsc: regressionIt was better in the past than it is nowcustomer: flask (g3)customer: googleVarious Google teamscustomer: thoughts (g3)f: selectionSelectableRegion, SelectionArea, SelectionContainer, Selectable, and related APIsfound in release: 3.29Found to occur in 3.29found in release: 3.32Found to occur in 3.32frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionteam-text-inputOwned by Text Input teamtriaged-text-inputTriaged by Text Input team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions