-
Notifications
You must be signed in to change notification settings - Fork 29.4k
Description
Issue Link
Target
stable
Cherry pick PR Link
Changelog Description
Fixes an issue where Flutter TextField may crash on iOS.
Impacted Users
Users of Flutter TextField on iOS, and users of BaseTapAndDragGestureRecognizer with eagerVictoryOnDrag set to false
Impact Description
On debug builds this triggers an assertion when using a TextField on iOS does a horizontal swipe or pan that doesn't meet the drag threshold to win the gesture arena and leaves TextField gestures in a weird state where no other tap gestures are accepted.
Workaround
No workaround, issue is with internal implementation of BaseTapAndDragGestureRecognizer
.
Risk
low
Test Coverage
yes
Validation Steps
Run the example below on iOS, tap the TextField
to focus it, and then do a horizontal drag somewhere not on the cursor. Then try to tap somewhere else. The cursor should be moved to the word edge closest to the tapped position.
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
final TextEditingController _controller = TextEditingController(text: 'Some long text that should scroll. ' * 20);
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
body: Center(
child: TextField(
controller: _controller,
maxLines: 5,
),
),
),
);
}
}