Repository navigation
AutofillContextAction.cancel in AutofillGroup#onDisposeAction does not work as expected on iPhone. #145681
Copy link
Copy link
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listfound in release: 3.19Found to occur in 3.19Found to occur in 3.19found in release: 3.21Found to occur in 3.21Found to occur in 3.21frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onplatform-iosiOS applications specificallyiOS applications specificallyr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-text-inputOwned by Text Input teamOwned by Text Input teamtriaged-text-inputTriaged by Text Input teamTriaged by Text Input team
Description
Steps to reproduce
- (developer) Prepare AutofillGroup
- Make username and password fields child elements.
- Set
onDisposeAction: AutofillContextAction.cancelfor AutofillGroup
- (user) enter username and password in the AutofillGroup child element
- 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
Code sample
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'),
),
),
);
}
}Screenshots or Video
Screenshots / Video demonstration
video.mp4
Logs
Logs
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.Flutter Doctor output
Doctor output
$ 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!Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listfound in release: 3.19Found to occur in 3.19Found to occur in 3.19found in release: 3.21Found to occur in 3.21Found to occur in 3.21frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onplatform-iosiOS applications specificallyiOS applications specificallyr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-text-inputOwned by Text Input teamOwned by Text Input teamtriaged-text-inputTriaged by Text Input teamTriaged by Text Input team
Activity
darshankawar commentedon Mar 26, 2024
Thanks for the report @koji-1009
I am not exactly clear as what is the current / actual bug and what's the expected behavior are you looking for ?
I tried the code sample locally and after entering user and pass and then hitting
go to third page, it shows the save password dialog.Also, the same save password dialog is displayed after we hit submit button.
Can you elaborate on the actual vs expected behavior ?
koji-1009 commentedon Mar 26, 2024
Thanks for the reply!
The sample code sets
AutofillContextAction.cancel. Therefore, displaying save password dialog on screen transition is not an expected behavior. I think this behavior is expected inAutofillContextAction.commit.https://api.flutter.dev/flutter/widgets/AutofillContextAction.html
AutofillContextAction.commitAutofillContextAction.cancelThe expected behavior is that the save password dialog is only displayed when the
submitbutton is pressed (with username and password entered).koji-1009 commentedon Mar 26, 2024
If you try it on an Android device, it works as expected. If necessary, I will take a video and attach it.
darshankawar commentedon Mar 27, 2024
Thanks for the update and info which makes it clear now what exactly the issue is, which I see the same behavior on latest versions.
stable, master flutter doctor -v
23 remaining items
flutter-triage-bot commentedon Aug 21, 2025
The
triaged-ioslabel is irrelevant if there is noteam-ioslabel orfyi-ioslabel.Revert flutter#160653 Fix view removal process for AutofillContextAct…
Revert flutter#160653 Fix view removal process for AutofillContextAct…
[ios][engine] Fix autofill context cleanup and view lifecycle managem…
github-actions commentedon Nov 10, 2025
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 -vand a minimal reproduction of the issue.[ios][engine] Fix autofill context cleanup and view lifecycle managem…
[ios][engine] Fix autofill context cleanup and view lifecycle managem…