From e6b1605b895836d460b6a270e8c6a3a037df0b8c Mon Sep 17 00:00:00 2001 From: Jorian van der Kolk Date: Tue, 25 Oct 2022 09:17:08 +0200 Subject: [PATCH] fixed keyboard closing ontap field --- .../widgets/item_builder/item_builder.dart | 29 +++++++++---------- lib/src/widgets/profile/proifle_wrapper.dart | 14 ++++----- 2 files changed, 19 insertions(+), 24 deletions(-) diff --git a/lib/src/widgets/item_builder/item_builder.dart b/lib/src/widgets/item_builder/item_builder.dart index 5a1e9fc..0625a0c 100644 --- a/lib/src/widgets/item_builder/item_builder.dart +++ b/lib/src/widgets/item_builder/item_builder.dart @@ -23,22 +23,19 @@ class ItemBuilder { inputDecoration = options.inputDecorationField?[key] ?? options.inputDecoration; - return Form( - key: formKey, - child: TextFormField( - key: Key(key), - controller: controller, - decoration: inputDecoration, - readOnly: options.readOnly, - onFieldSubmitted: (value) { - if (formKey.currentState!.validate()) { - updateItem(value); - } - }, - validator: (value) { - return options.validators?[key]?.call(value); - }, - ), + return TextFormField( + key: Key(key), + controller: controller, + decoration: inputDecoration, + readOnly: options.readOnly, + onFieldSubmitted: (value) { + if (formKey.currentState!.validate()) { + updateItem(value); + } + }, + validator: (value) { + return options.validators?[key]?.call(value); + }, ); } return widget; diff --git a/lib/src/widgets/profile/proifle_wrapper.dart b/lib/src/widgets/profile/proifle_wrapper.dart index 9eb927f..4a021b0 100644 --- a/lib/src/widgets/profile/proifle_wrapper.dart +++ b/lib/src/widgets/profile/proifle_wrapper.dart @@ -46,9 +46,7 @@ class ProfileWrapper extends StatefulWidget { class _ProfileWrapperState extends State { List defaultItems = []; - GlobalKey firstNameKey = GlobalKey(); - - GlobalKey lastNameKey = GlobalKey(); + GlobalKey formKey = GlobalKey(); @override void initState() { @@ -61,7 +59,7 @@ class _ProfileWrapperState extends State { defaultItems.add( builder.build( 'first_name', - firstNameKey, + formKey, widget.user.firstName, null, (v) { @@ -79,7 +77,7 @@ class _ProfileWrapperState extends State { defaultItems.add( builder.build( 'last_name', - lastNameKey, + formKey, widget.user.lastName, null, (v) { @@ -98,7 +96,7 @@ class _ProfileWrapperState extends State { defaultItems.add( widget.itemBuilder!.build( 'first_name', - firstNameKey, + formKey, widget.user.firstName, null, (v) { @@ -116,7 +114,7 @@ class _ProfileWrapperState extends State { defaultItems.add( widget.itemBuilder!.build( 'last_name', - lastNameKey, + formKey, widget.user.lastName, null, (v) { @@ -197,7 +195,7 @@ class _ProfileWrapperState extends State { ), ], // all the items that have priority above the default items - child, + Form(key: formKey, child: child), if (widget.bottomActionText != null) ...[ SizedBox( height: widget.style.betweenDefaultItemPadding,