Skip to content

Instantly share code, notes, and snippets.

@truongsinh
Created August 6, 2020 02:42
Show Gist options
  • Save truongsinh/506e9a982d19ff02874cf00043a0f9ed to your computer and use it in GitHub Desktop.
Save truongsinh/506e9a982d19ff02874cf00043a0f9ed to your computer and use it in GitHub Desktop.
step 5 uniquekey
diff --git a/lib/main.dart b/lib/main.dart
index 439d0fb..fafcf3a 100644
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -27,6 +27,9 @@ class MyStatefulWidget extends StatefulWidget {
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
var isSameAddress = true;
+ final billingAddress1Key = UniqueKey();
+ final billingAddress2Key = UniqueKey();
+
// For the sake of simplicity, Form widget, _formkey, and textController
// has been removed
@@ -68,6 +71,7 @@ class _MyStatefulWidgetState extends State<MyStatefulWidget> {
child: Column(
children: [
TextFormField(
+ key: billingAddress1Key,
autofillHints: [AutofillHints.streetAddressLine1],
decoration: const InputDecoration(
labelText: 'Billing address 1',
@@ -75,6 +79,7 @@ class _MyStatefulWidgetState extends State<MyStatefulWidget> {
),
),
TextFormField(
+ key: billingAddress2Key,
autofillHints: [AutofillHints.streetAddressLine2],
decoration: const InputDecoration(
labelText: 'Billing address 2',
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment