Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The behavior of Dismissible with TextFormFields is different for Android and iOS #142447

Closed
maxmitz opened this issue Jan 29, 2024 · 3 comments · Fixed by #147341
Closed

The behavior of Dismissible with TextFormFields is different for Android and iOS #142447

maxmitz opened this issue Jan 29, 2024 · 3 comments · Fixed by #147341
Assignees
Labels
a: text input Entering text in a text field or keyboard related problems c: parity Works on one platform but not another f: gestures flutter/packages/flutter/gestures repository. f: material design flutter/packages/flutter/material repository. found in release: 3.16 Found to occur in 3.16 found in release: 3.19 Found to occur in 3.19 framework flutter/packages/flutter repository. See also f: labels. has reproducible steps The issue has been confirmed reproducible and is ready to work on P2 Important issues not at the top of the work list platform-android Android applications specifically platform-ios iOS applications specifically r: fixed Issue is closed as already fixed in a newer version team-design Owned by Design Languages team triaged-design Triaged by Design Languages team

Comments

@maxmitz
Copy link

maxmitz commented Jan 29, 2024

Steps to reproduce

  1. Run the code sample on Android and iOS.
  2. Dismiss an item with the red SizedBox and the TextFormField part.

Expected results

The behavior should be the same on iOS and Android. In my opinion, it should on both platforms be possible to dismiss by sliding the TextFormField.

If the TextField takes up the entire Dismissible, then it will handle the gesture.
This is also not true for iOS.

Actual results

On Android you can dismiss an item by touching the red SizedBox part but also the TextFormField part.
On iOS you can dismiss an item only by touching the red SizedBox part but not the TextFormField part.

Code sample

Code sample
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key});

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  List<int> items = List<int>.generate(10, (index) => index);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: ListView.builder(
          itemCount: items.length,
          itemBuilder: (_, index) => Dismissible(
              key: ValueKey<int>(items[index]),
              onDismissed: (DismissDirection direction) {
                setState(() {
                  items.removeAt(index);
                });
              },
              child: Row(
                children: [
                  Container(
                    width: 50,
                    height: 30,
                    color: Colors.red,
                  ),
                  SizedBox(
                      width: 200,
                      child: TextFormField(
                        initialValue: items[index].toString(),
                      )),
                  Container(
                    width: 50,
                    height: 30,
                    color: Colors.red,
                  ),
                ],
              ))),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration
Bildschirmaufnahme.2024-01-29.um.17.33.24.mov
Bildschirmaufnahme.2024-01-29.um.17.30.26.mov

Flutter Doctor output

Doctor output
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.16.5, on macOS 14.0 23A344 darwin-arm64, locale de-DE)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
[✓] Xcode - develop for iOS and macOS (Xcode 15.0)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.3)
[✓] VS Code (version 1.85.1)
[✓] Connected device (5 available)
[✓] Network resources

• No issues found!```

</details>
@Hyla96
Copy link

Hyla96 commented Jan 30, 2024

The issue has something to do with the field implementing gestures for the text selection.

If you replace the field with a Gesture detector and pass onHorizontalDragUpdate you get the same behavior you get on iOS (but you get it on both platforms). (It doesn't happen if you define only onTap)

I believe that the field widget implements some platform-specific logic that defines (only for iOS) the dragging behavior for the RawGestureDetector underneath.

My results by running gesture arena:

Android

I/flutter ( 6180): Gesture arena 1    ❙ ★ Opening new gesture arena.
I/flutter ( 6180): Gesture arena 1    ❙ Adding: LongPressGestureRecognizer#c7fd1(debugOwner: _TextSelectionGestureDetectorState#74587, state: ready)
I/flutter ( 6180): Gesture arena 1    ❙ Adding: TapAndHorizontalDragGestureRecognizer#bc5ef(debugOwner: _TextSelectionGestureDetectorState#74587)
I/flutter ( 6180): Gesture arena 1    ❙ Adding: HorizontalDragGestureRecognizer#bb172(debugOwner: GestureDetector, start behavior: start)
I/flutter ( 6180): Gesture arena 1    ❙ Adding: VerticalDragGestureRecognizer#ba151(start behavior: start)
I/flutter ( 6180): Gesture arena 1    ❙ Closing with 4 members.
I/flutter ( 6180): Gesture arena 1    ❙ Accepting: HorizontalDragGestureRecognizer#bb172(debugOwner: GestureDetector, start behavior: start)
I/flutter ( 6180): Gesture arena 1    ❙ Self-declared winner: HorizontalDragGestureRecognizer#bb172(debugOwner: GestureDetector, start behavior: start)

iOS

flutter: Gesture arena 13   ❙ ★ Opening new gesture arena.
flutter: Gesture arena 13   ❙ Adding: LongPressGestureRecognizer#8310a(debugOwner: _TextSelectionGestureDetectorState#bcacb, state: ready)
flutter: Gesture arena 13   ❙ Adding: TapAndHorizontalDragGestureRecognizer#5e5b9(debugOwner: _TextSelectionGestureDetectorState#bcacb)
flutter: Gesture arena 13   ❙ Adding: HorizontalDragGestureRecognizer#e568a(debugOwner: GestureDetector, start behavior: start)
flutter: Gesture arena 13   ❙ Adding: VerticalDragGestureRecognizer#fccbd(start behavior: start)
flutter: Gesture arena 13   ❙ Closing with 4 members.
flutter: Gesture arena 13   ❙ Rejecting: LongPressGestureRecognizer#8310a(debugOwner: _TextSelectionGestureDetectorState#bcacb, state: possible)
flutter: Gesture arena 13   ❙ Accepting: TapAndHorizontalDragGestureRecognizer#5e5b9(debugOwner: _TextSelectionGestureDetectorState#bcacb)
flutter: Gesture arena 13   ❙ Self-declared winner: TapAndHorizontalDragGestureRecognizer#5e5b9(debugOwner: _TextSelectionGestureDetectorState#bcacb)

@darshankawar darshankawar added the in triage Presently being triaged by the triage team label Jan 30, 2024
@darshankawar
Copy link
Member

Thanks for the report. I was able to see the same behavior as observed on both platforms. The same is noticed using the official code sample (by replacing Text with TextField).

I looked at native iOS app (Reminders) and observed that the swiping from center area which is clickable, is possible.

RPReplay-Final1706597997.MOV

If the TextField takes up the entire Dismissible, then it will handle the gesture.
This is also not true for iOS.

Updated the code from above link and running on both platform still gives the same behavior as reported.

stable, master flutter doctor -v
[!] Flutter (Channel stable, 3.16.8, on macOS 12.2.1 21D62 darwin-x64, locale
    en-GB)
    • Flutter version 3.16.8 on channel stable at
      /Users/dhs/documents/fluttersdk/flutter
    ! Warning: `flutter` on your path resolves to
      /Users/dhs/Documents/Fluttersdk/flutter/bin/flutter, which is not inside
      your current Flutter SDK checkout at
      /Users/dhs/documents/fluttersdk/flutter. Consider adding
      /Users/dhs/documents/fluttersdk/flutter/bin to the front of your path.
    ! Warning: `dart` on your path resolves to
      /Users/dhs/Documents/Fluttersdk/flutter/bin/dart, which is not inside your
      current Flutter SDK checkout at /Users/dhs/documents/fluttersdk/flutter.
      Consider adding /Users/dhs/documents/fluttersdk/flutter/bin to the front
      of your path.
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 67457e669f (2 days ago), 2024-01-16 16:22:29 -0800
    • Engine revision 6e2ea58a5c
    • Dart version 3.2.5
    • DevTools version 2.28.5
    • If those were intentional, you can disregard the above warnings; however
      it is recommended to use "git" directly to perform update checks and
      upgrades.

[!] Xcode - develop for iOS and macOS (Xcode 12.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    ! Flutter recommends a minimum Xcode version of 13.
      Download the latest version or update via the Mac App Store.
    • CocoaPods version 1.11.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] VS Code (version 1.62.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.21.0

[✓] Connected device (5 available)
    • SM G975F (mobile)       • RZ8M802WY0X • android-arm64   • Android 11 (API 30)
    • Darshan's iphone (mobile)  • 21150b119064aecc249dfcfe05e259197461ce23 •
      ios            • iOS 14.4.1 18D61
    • iPhone 12 Pro Max (mobile) • A5473606-0213-4FD8-BA16-553433949729     •
      ios            • com.apple.CoreSimulator.SimRuntime.iOS-14-3 (simulator)
    • macOS (desktop)            • macos                                    •
      darwin-x64     • Mac OS X 10.15.4 19E2269 darwin-x64
    • Chrome (web)               • chrome                                   •
      web-javascript • Google Chrome 98.0.4758.80

[✓] HTTP Host Availability
    • All required HTTP hosts are available

! Doctor found issues in 1 category.

[!] Flutter (Channel master, 3.19.0-13.0.pre.29, on macOS 12.2.1 21D62
    darwin-x64, locale en-GB)
    • Flutter version 3.19.0-13.0.pre.29 on channel master at
      /Users/dhs/documents/fluttersdk/flutter
    ! Warning: `flutter` on your path resolves to
      /Users/dhs/Documents/Fluttersdk/flutter/bin/flutter, which is not inside
      your current Flutter SDK checkout at
      /Users/dhs/documents/fluttersdk/flutter. Consider adding
      /Users/dhs/documents/fluttersdk/flutter/bin to the front of your path.
    ! Warning: `dart` on your path resolves to
      /Users/dhs/Documents/Fluttersdk/flutter/bin/dart, which is not inside your
      current Flutter SDK checkout at /Users/dhs/documents/fluttersdk/flutter.
      Consider adding /Users/dhs/documents/fluttersdk/flutter/bin to the front
      of your path.
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 5c64d0370b (2 hours ago), 2024-01-29 22:21:25 -0500
    • Engine revision ed73d40a8c
    • Dart version 3.4.0 (build 3.4.0-82.0.dev)
    • DevTools version 2.31.0
    • If those were intentional, you can disregard the above warnings; however
      it is recommended to use "git" directly to perform update checks and
      upgrades.

[!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /Users/dhs/Library/Android/sdk
    ✗ cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/macos#android-setup for
      more details.

[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 13C100
    • CocoaPods version 1.11.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] IntelliJ IDEA Ultimate Edition (version 2021.3.2)
    • IntelliJ at /Applications/IntelliJ IDEA.app
    • Flutter plugin version 65.1.4
    • Dart plugin version 213.7228

[✓] VS Code (version 1.62.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.29.0

[✓] Connected device (3 available)
    • Darshan's iphone (mobile) • 21150b119064aecc249dfcfe05e259197461ce23 • ios
      • iOS 15.3.1 19D52
    • macOS (desktop)           • macos                                    •
      darwin-x64     • macOS 12.2.1 21D62 darwin-x64
    • Chrome (web)              • chrome                                   •
      web-javascript • Google Chrome 109.0.5414.119

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 1 category.
      
[!] Xcode - develop for iOS and macOS (Xcode 12.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    ! Flutter recommends a minimum Xcode version of 13.
      Download the latest version or update via the Mac App Store.
    • CocoaPods version 1.11.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] VS Code (version 1.62.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.21.0

[✓] Connected device (5 available)
    • SM G975F (mobile)       • RZ8M802WY0X • android-arm64   • Android 11 (API 30)
    • Darshan's iphone (mobile)  • 21150b119064aecc249dfcfe05e259197461ce23 •
      ios            • iOS 14.4.1 18D61
    • iPhone 12 Pro Max (mobile) • A5473606-0213-4FD8-BA16-553433949729     •
      ios            • com.apple.CoreSimulator.SimRuntime.iOS-14-3 (simulator)
    • macOS (desktop)            • macos                                    •
      darwin-x64     • Mac OS X 10.15.4 19E2269 darwin-x64
    • Chrome (web)               • chrome                                   •
      web-javascript • Google Chrome 98.0.4758.80

[✓] HTTP Host Availability
    • All required HTTP hosts are available

! Doctor found issues in 1 category.



@darshankawar darshankawar added a: text input Entering text in a text field or keyboard related problems platform-android Android applications specifically platform-ios iOS applications specifically framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. f: gestures flutter/packages/flutter/gestures repository. has reproducible steps The issue has been confirmed reproducible and is ready to work on found in release: 3.16 Found to occur in 3.16 found in release: 3.19 Found to occur in 3.19 team-design Owned by Design Languages team c: parity Works on one platform but not another and removed in triage Presently being triaged by the triage team labels Jan 30, 2024
@justinmc justinmc added P2 Important issues not at the top of the work list triaged-design Triaged by Design Languages team labels Feb 1, 2024
@Renzo-Olivares Renzo-Olivares linked a pull request Apr 30, 2024 that will close this issue
9 tasks
@auto-submit auto-submit bot closed this as completed in 5181086 May 1, 2024
@darshankawar darshankawar added the r: fixed Issue is closed as already fixed in a newer version label May 2, 2024
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a: text input Entering text in a text field or keyboard related problems c: parity Works on one platform but not another f: gestures flutter/packages/flutter/gestures repository. f: material design flutter/packages/flutter/material repository. found in release: 3.16 Found to occur in 3.16 found in release: 3.19 Found to occur in 3.19 framework flutter/packages/flutter repository. See also f: labels. has reproducible steps The issue has been confirmed reproducible and is ready to work on P2 Important issues not at the top of the work list platform-android Android applications specifically platform-ios iOS applications specifically r: fixed Issue is closed as already fixed in a newer version team-design Owned by Design Languages team triaged-design Triaged by Design Languages team
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants