Skip to content

[CP-Stable] Fix BaseTapAndDragGestureRecognizer drag state after losing gesture arena #153939

@Renzo-Olivares

Description

@Renzo-Olivares

Issue Link

#153458

Target

stable

Cherry pick PR Link

#153935

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,
          ),
        ),
      ),
    );
  }
}

Metadata

Metadata

Assignees

Labels

cp: reviewCherry-picks in the review queue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions