mirror of
https://github.com/Iconica-Development/flutter_profile.git
synced 2025-05-19 01:03:45 +02:00
Merge pull request #9 from Iconica-Development/hotfix/validate-single-field
Hotfix/validate single field
This commit is contained in:
commit
f4d422ac05
4 changed files with 6 additions and 12 deletions
|
@ -11,8 +11,8 @@ class ItemBuilder {
|
|||
|
||||
final ItemBuilderOptions options;
|
||||
|
||||
Widget build(String key, GlobalKey<FormState> 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<FormFieldState>();
|
||||
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);
|
||||
}
|
||||
},
|
||||
|
|
|
@ -38,7 +38,6 @@ class _ItemListState extends State<ItemList> {
|
|||
? widgets.add(
|
||||
builder.build(
|
||||
item.key,
|
||||
widget.formKey,
|
||||
item.value,
|
||||
widget.typeMap[item.key],
|
||||
(value) {
|
||||
|
@ -49,7 +48,6 @@ class _ItemListState extends State<ItemList> {
|
|||
: widgets.add(
|
||||
widget.itemBuilder!.build(
|
||||
item.key,
|
||||
widget.formKey,
|
||||
item.value,
|
||||
widget.typeMap[item.key],
|
||||
(value) {
|
||||
|
|
|
@ -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:
|
||||
///
|
||||
|
|
|
@ -59,7 +59,6 @@ class _ProfileWrapperState extends State<ProfileWrapper> {
|
|||
defaultItems.add(
|
||||
builder.build(
|
||||
'first_name',
|
||||
formKey,
|
||||
widget.user.firstName,
|
||||
null,
|
||||
(v) {
|
||||
|
@ -77,7 +76,6 @@ class _ProfileWrapperState extends State<ProfileWrapper> {
|
|||
defaultItems.add(
|
||||
builder.build(
|
||||
'last_name',
|
||||
formKey,
|
||||
widget.user.lastName,
|
||||
null,
|
||||
(v) {
|
||||
|
@ -96,7 +94,6 @@ class _ProfileWrapperState extends State<ProfileWrapper> {
|
|||
defaultItems.add(
|
||||
widget.itemBuilder!.build(
|
||||
'first_name',
|
||||
formKey,
|
||||
widget.user.firstName,
|
||||
null,
|
||||
(v) {
|
||||
|
@ -114,7 +111,6 @@ class _ProfileWrapperState extends State<ProfileWrapper> {
|
|||
defaultItems.add(
|
||||
widget.itemBuilder!.build(
|
||||
'last_name',
|
||||
formKey,
|
||||
widget.user.lastName,
|
||||
null,
|
||||
(v) {
|
Loading…
Reference in a new issue