From d2975780fc3f9d1e2d74b8511c8ced41206248d4 Mon Sep 17 00:00:00 2001 From: Jorian van der Kolk Date: Fri, 28 Oct 2022 14:08:29 +0200 Subject: [PATCH 1/2] rename proifle_wrapper to profile_wrapper --- lib/src/widgets/profile/profile_page.dart | 2 +- .../profile/{proifle_wrapper.dart => profile_wrapper.dart} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename lib/src/widgets/profile/{proifle_wrapper.dart => profile_wrapper.dart} (100%) diff --git a/lib/src/widgets/profile/profile_page.dart b/lib/src/widgets/profile/profile_page.dart index 54cc5c6..9493418 100644 --- a/lib/src/widgets/profile/profile_page.dart +++ b/lib/src/widgets/profile/profile_page.dart @@ -4,7 +4,7 @@ import 'package:flutter_profile/src/services/profile_service.dart'; import 'package:flutter_profile/src/widgets/item_builder/item_builder.dart'; import 'package:flutter_profile/src/widgets/item_builder/item_builder_options.dart'; import 'package:flutter_profile/src/widgets/profile/profile_style.dart'; -import 'package:flutter_profile/src/widgets/profile/proifle_wrapper.dart'; +import 'package:flutter_profile/src/widgets/profile/profile_wrapper.dart'; /// The ProfilePage widget is able to show the data of a user. By default the user is able to change this data. The widget has a couple of parameters listed below: /// diff --git a/lib/src/widgets/profile/proifle_wrapper.dart b/lib/src/widgets/profile/profile_wrapper.dart similarity index 100% rename from lib/src/widgets/profile/proifle_wrapper.dart rename to lib/src/widgets/profile/profile_wrapper.dart From c516ce8f22dfd8c655e3a2d6826b9cd9603ddc31 Mon Sep 17 00:00:00 2001 From: Jorian van der Kolk Date: Fri, 28 Oct 2022 14:12:40 +0200 Subject: [PATCH 2/2] only validate edited field --- lib/src/widgets/item_builder/item_builder.dart | 10 +++++----- lib/src/widgets/item_builder/item_list.dart | 2 -- lib/src/widgets/profile/profile_wrapper.dart | 4 ---- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/lib/src/widgets/item_builder/item_builder.dart b/lib/src/widgets/item_builder/item_builder.dart index 0625a0c..de86bfe 100644 --- a/lib/src/widgets/item_builder/item_builder.dart +++ b/lib/src/widgets/item_builder/item_builder.dart @@ -11,8 +11,8 @@ class ItemBuilder { final ItemBuilderOptions options; - Widget build(String key, GlobalKey formKey, dynamic value, - Widget? widget, Function(String) updateItem) { + Widget build( + String key, dynamic value, Widget? widget, Function(String) updateItem) { if (widget == null) { var controller = TextEditingController( text: '${value ?? ''}', @@ -22,14 +22,14 @@ class ItemBuilder { inputDecoration = options.inputDecorationField?[key] ?? options.inputDecoration; - + var formFieldKey = GlobalKey(); return TextFormField( - key: Key(key), + key: formFieldKey, controller: controller, decoration: inputDecoration, readOnly: options.readOnly, onFieldSubmitted: (value) { - if (formKey.currentState!.validate()) { + if (formFieldKey.currentState!.validate()) { updateItem(value); } }, diff --git a/lib/src/widgets/item_builder/item_list.dart b/lib/src/widgets/item_builder/item_list.dart index 6cdd2d2..cba9d5b 100644 --- a/lib/src/widgets/item_builder/item_list.dart +++ b/lib/src/widgets/item_builder/item_list.dart @@ -38,7 +38,6 @@ class _ItemListState extends State { ? widgets.add( builder.build( item.key, - widget.formKey, item.value, widget.typeMap[item.key], (value) { @@ -49,7 +48,6 @@ class _ItemListState extends State { : widgets.add( widget.itemBuilder!.build( item.key, - widget.formKey, item.value, widget.typeMap[item.key], (value) { diff --git a/lib/src/widgets/profile/profile_wrapper.dart b/lib/src/widgets/profile/profile_wrapper.dart index 5adad1c..6a822a6 100644 --- a/lib/src/widgets/profile/profile_wrapper.dart +++ b/lib/src/widgets/profile/profile_wrapper.dart @@ -59,7 +59,6 @@ class _ProfileWrapperState extends State { defaultItems.add( builder.build( 'first_name', - formKey, widget.user.firstName, null, (v) { @@ -77,7 +76,6 @@ class _ProfileWrapperState extends State { defaultItems.add( builder.build( 'last_name', - formKey, widget.user.lastName, null, (v) { @@ -96,7 +94,6 @@ class _ProfileWrapperState extends State { defaultItems.add( widget.itemBuilder!.build( 'first_name', - formKey, widget.user.firstName, null, (v) { @@ -114,7 +111,6 @@ class _ProfileWrapperState extends State { defaultItems.add( widget.itemBuilder!.build( 'last_name', - formKey, widget.user.lastName, null, (v) {