Repository: flutter
Issue: `AutofillContextAction.cancel` in `AutofillGroup#onDisposeAction` does not work as expected on iPhone.
Labels: platform-ios,framework,has reproducible steps,found in release: 3.19,team-text-input,found in release: 3.21

### Steps to reproduce

1. (developer) Prepare AutofillGroup
   * Make username and password fields child elements.
   * Set `onDisposeAction: AutofillContextAction.cancel` for AutofillGroup
2. (user) enter username and password in the AutofillGroup child element
3. return to previous screen or go to next screen

### Expected results

A sheet for saving username and password is not displayed.

### Actual results

A sheet for saving username and password is displayed.

### Code sample

<details open><summary>Code sample</summary>

```dart
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

void main() {
  runApp(const App());
}

class App extends StatelessWidget {
  const App({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter autofill issue',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(
          seedColor: Colors.deepPurple,
        ),
      ),
      home: const FirstPage(),
    );
  }
}

class FirstPage extends StatelessWidget {
  const FirstPage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('First Page'),
      ),
      body: Center(
        child: FilledButton(
          onPressed: () {
            Navigator.of(context).push(
              MaterialPageRoute(
                builder: (context) => const SecondPage(),
              ),
            );
          },
          child: const Text('Go to Second Page'),
        ),
      ),
    );
  }
}

class SecondPage extends StatelessWidget {
  const SecondPage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Second Page'),
      ),
      body: Padding(
        padding: const EdgeInsets.all(16),
        child: AutofillGroup(
          onDisposeAction: AutofillContextAction.cancel,
          child: Column(
            children: [
              const TextField(
                decoration: InputDecoration(
                  labelText: 'Username',
                ),
                autofillHints: [
                  AutofillHints.username,
                ],
              ),
              const SizedBox(
                height: 16,
              ),
              const TextField(
                decoration: InputDecoration(
                  labelText: 'Password',
                ),
                autofillHints: [
                  AutofillHints.password,
                ],
              ),
              const SizedBox(
                height: 16,
              ),
              FilledButton(
                onPressed: () {
                  TextInput.finishAutofillContext(
                    shouldSave: true,
                  );
                },
                child: const Text('Submit'),
              ),
              const SizedBox(
                height: 16,
              ),
              FilledButton(
                onPressed: () {
                  Navigator.of(context).push(
                    MaterialPageRoute(
                      builder: (context) => const ThirdPage(),
                    ),
                  );
                },
                child: const Text('Go to Third Page'),
              ),
            ],
          ),
        ),
      ),
    );
  }
}

class ThirdPage extends StatelessWidget {
  const ThirdPage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Third Page'),
      ),
      body: Center(
        child: FilledButton(
          onPressed: () {
            Navigator.of(context).pop();
          },
          child: const Text('Go back to Second Page'),
        ),
      ),
    );
  }
}
```

</details>


### Screenshots or Video

<details open>
<summary>Screenshots / Video demonstration</summary>

https://github.com/flutter/flutter/assets/17231507/095d59d9-e32c-47dc-8de0-0241761734fa

</details>


### Logs

<details open><summary>Logs</summary>

```console
Launching lib/main.dart on iPhone Xs in debug mode...
Running Xcode build...
Xcode build done.                                            5.3s
[ERROR:flutter/shell/platform/darwin/graphics/FlutterDarwinContextMetalImpeller.mm(42)] Using the Impeller rendering backend.
Debug service listening on ws://127.0.0.1:53891/st0zbwSK1OA=/ws
Syncing files to device iPhone Xs...
Application finished.
```

</details>


### Flutter Doctor output

<details open><summary>Doctor output</summary>

```console
$ flutter doctor -v
[✓] Flutter (Channel stable, 3.19.4, on macOS 14.4 23E214 darwin-arm64, locale
    ja-JP)
    • Flutter version 3.19.4 on channel stable at /Users/koji/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 68bfaea224 (5 days ago), 2024-03-20 15:36:31 -0700
    • Engine revision a5c24f538d
    • Dart version 3.3.2
    • DevTools version 2.31.1

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/koji/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • ANDROID_HOME = /Users/koji/Library/Android/sdk
    • ANDROID_SDK_ROOT = /Users/koji/Library/Android/sdk
    • Java binary at: /Applications/Android
      Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build
      17.0.9+0-17.0.9b1087.7-11185874)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15E204a
    • CocoaPods version 1.15.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2023.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build
      17.0.9+0-17.0.9b1087.7-11185874)

[✓] IntelliJ IDEA Community Edition (version 2023.3.6)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin version 78.4.2
    • Dart plugin version 233.15026.12

[✓] VS Code (version 1.87.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.84.0

[✓] Connected device (3 available)
    • iPhone Xs (mobile) • 0E4C5F44-27EB-4EA3-9FCB-C6605D110BF5 • ios
      • com.apple.CoreSimulator.SimRuntime.iOS-17-4 (simulator)
    • macOS (desktop)    • macos                                • darwin-arm64
      • macOS 14.4 23E214 darwin-arm64
    • Chrome (web)       • chrome                               • web-javascript
      • Google Chrome 123.0.6312.59

[✓] Network resources
    • All expected network resources are available.

• No issues found!
```

</details>