-
Notifications
You must be signed in to change notification settings - Fork 30.2k
AutofillGroup not working as expected #118030
Copy link
Copy link
Closed as not planned
Labels
r: duplicateIssue is closed as a duplicate of an existing issueIssue is closed as a duplicate of an existing issuewaiting for customer responseThe Flutter team cannot make further progress on this issue until the original reporter respondsThe Flutter team cannot make further progress on this issue until the original reporter responds
Description
Steps to Reproduce
- fill the username&password textfield
- press the ‘other page’ button
- press the ‘submit’ button
Expected results:
When i press the 'other page' button,the app doesn't show the system prompt
When i press the 'submit' button,the app show the system prompt
When the prompt is closed, the page will not jump up and down
Actual results:
When i press the 'other page' button,the app show the system prompt
When the prompt is closed, the page will jump up and down
Code sample
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
static const String _title = 'Flutter Code Sample';
@override
Widget build(BuildContext context) {
return MaterialApp(
title: _title,
home: Scaffold(
appBar: AppBar(title: const Text(_title)),
body: MyStatefulWidget(),
),
);
}
}
class MyStatefulWidget extends StatefulWidget {
const MyStatefulWidget({Key? key}) : super(key: key);
@override
_MyStatefulWidgetState createState() => _MyStatefulWidgetState();
}
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
var isSameAddress = true;
final billingAddress1Key = UniqueKey();
final billingAddress2Key = UniqueKey();
final _formKey = GlobalKey<FormState>();
@override
Widget build(BuildContext context) => Form(
key: _formKey,
child: AutofillGroup(
onDisposeAction: AutofillContextAction.cancel,
child: ListView(
padding: EdgeInsets.symmetric(horizontal: 16),
children: [
Column(
children: [
TextFormField(
autofillHints: [AutofillHints.username],
// validator: (value) =>
// value!.isEmpty ? "some email please" : null,
decoration: const InputDecoration(
labelText: 'username',
hintText: 'enter username adress',
),
),
TextFormField(
autofillHints: [AutofillHints.password],
validator: (value) =>
value!.isEmpty ? "some password please" : null,
decoration: const InputDecoration(
labelText: 'password',
hintText: 'enter your password',
),
),
],
),
MaterialButton(
child: Text("submit"),
onPressed: () {
// if (_formKey.currentState!.validate()) {
TextInput.finishAutofillContext(shouldSave: true);
debugPrint("----> Naigate to 2nd Page");
Navigator.push(
context,
MaterialPageRoute(builder: (context) => SecondRoute()),
);
// }
},
),
MaterialButton(
child: Text("other page"),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => ThirdRoute()),
);
},
),
],
),
),
);
@override
void dispose() {
debugPrint("Form widget disposed");
super.dispose();
}
}
class SecondRoute extends StatefulWidget {
@override
_SecondRouteState createState() => _SecondRouteState();
}
class _SecondRouteState extends State<SecondRoute> {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.red,
// resizeToAvoidBottomInset: false,
appBar: AppBar(
title: Text("Second Route"),
),
body: Center(
child: ElevatedButton(
onPressed: () {
debugPrint("----> Naigate back to first page");
Navigator.pop(context);
//Navigator.pushReplacement(context, MaterialPageRoute(builder: (context) => MyApp()));
},
child: Text('Go back!'),
),
),
);
}
@override
void dispose() {
debugPrint("2nd Screen widget disposed");
super.dispose();
}
}
class ThirdRoute extends StatefulWidget {
@override
_ThirdRouteState createState() => _ThirdRouteState();
}
class _ThirdRouteState extends State<ThirdRoute> {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.red,
// resizeToAvoidBottomInset: false,
appBar: AppBar(
title: Text("third Route"),
),
body: Center(
child: ElevatedButton(
onPressed: () {
debugPrint("----> Naigate back to first page");
Navigator.pop(context);
//Navigator.pushReplacement(context, MaterialPageRoute(builder: (context) => MyApp()));
},
child: Text('Go back!'),
),
),
);
}
@override
void dispose() {
super.dispose();
}
}
Logs
flutter analyze
Analyzing autofill_example-master 2...
No issues found! (ran in 2.6s)
flutter doctor -v
[✓] Flutter (Channel stable, 3.3.0, on macOS 11.3.1 20E241 darwin-x64, locale zh-Hans-CN)
• Flutter version 3.3.0 on channel stable at /Users/blake/fvm/versions/3.3.0
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision ffccd96b62 (4 个月前), 2022-08-29 17:28:57 -0700
• Engine revision 5e9e0e0aa8
• Dart version 2.18.0
• DevTools version 2.15.0
• Pub download mirror https://pub.flutter-io.cn
• Flutter download mirror https://storage.flutter-io.cn
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
• Android SDK at /Users/blake/Library/Android/sdk
• Platform android-33, build-tools 31.0.0
• ANDROID_HOME = /Users/blake/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 13.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 13A1030d
• CocoaPods version 1.11.2
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2020.3)
• 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 11.0.10+0-b96-7281165)
[✓] VS Code (version 1.74.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.56.0
[✓] Connected device (3 available)
• 树上的男爵i (mobile) • 00008101-000D39681A22001E • ios • iOS 15.3 19D50
• macOS (desktop) • macos • darwin-x64 • macOS 11.3.1 20E241 darwin-x64
• Chrome (web) • chrome • web-javascript • Google Chrome 108.0.5359.124
[✓] HTTP Host Availability
• All required HTTP hosts are available
• No issues found!
RPReplay_Final1672909184.MP4
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
r: duplicateIssue is closed as a duplicate of an existing issueIssue is closed as a duplicate of an existing issuewaiting for customer responseThe Flutter team cannot make further progress on this issue until the original reporter respondsThe Flutter team cannot make further progress on this issue until the original reporter responds