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;
|
final ItemBuilderOptions options;
|
||||||
|
|
||||||
Widget build(String key, GlobalKey<FormState> formKey, dynamic value,
|
Widget build(
|
||||||
Widget? widget, Function(String) updateItem) {
|
String key, dynamic value, Widget? widget, Function(String) updateItem) {
|
||||||
if (widget == null) {
|
if (widget == null) {
|
||||||
var controller = TextEditingController(
|
var controller = TextEditingController(
|
||||||
text: '${value ?? ''}',
|
text: '${value ?? ''}',
|
||||||
|
@ -22,14 +22,14 @@ class ItemBuilder {
|
||||||
|
|
||||||
inputDecoration =
|
inputDecoration =
|
||||||
options.inputDecorationField?[key] ?? options.inputDecoration;
|
options.inputDecorationField?[key] ?? options.inputDecoration;
|
||||||
|
var formFieldKey = GlobalKey<FormFieldState>();
|
||||||
return TextFormField(
|
return TextFormField(
|
||||||
key: Key(key),
|
key: formFieldKey,
|
||||||
controller: controller,
|
controller: controller,
|
||||||
decoration: inputDecoration,
|
decoration: inputDecoration,
|
||||||
readOnly: options.readOnly,
|
readOnly: options.readOnly,
|
||||||
onFieldSubmitted: (value) {
|
onFieldSubmitted: (value) {
|
||||||
if (formKey.currentState!.validate()) {
|
if (formFieldKey.currentState!.validate()) {
|
||||||
updateItem(value);
|
updateItem(value);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -38,7 +38,6 @@ class _ItemListState extends State<ItemList> {
|
||||||
? widgets.add(
|
? widgets.add(
|
||||||
builder.build(
|
builder.build(
|
||||||
item.key,
|
item.key,
|
||||||
widget.formKey,
|
|
||||||
item.value,
|
item.value,
|
||||||
widget.typeMap[item.key],
|
widget.typeMap[item.key],
|
||||||
(value) {
|
(value) {
|
||||||
|
@ -49,7 +48,6 @@ class _ItemListState extends State<ItemList> {
|
||||||
: widgets.add(
|
: widgets.add(
|
||||||
widget.itemBuilder!.build(
|
widget.itemBuilder!.build(
|
||||||
item.key,
|
item.key,
|
||||||
widget.formKey,
|
|
||||||
item.value,
|
item.value,
|
||||||
widget.typeMap[item.key],
|
widget.typeMap[item.key],
|
||||||
(value) {
|
(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.dart';
|
||||||
import 'package:flutter_profile/src/widgets/item_builder/item_builder_options.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/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:
|
/// 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(
|
defaultItems.add(
|
||||||
builder.build(
|
builder.build(
|
||||||
'first_name',
|
'first_name',
|
||||||
formKey,
|
|
||||||
widget.user.firstName,
|
widget.user.firstName,
|
||||||
null,
|
null,
|
||||||
(v) {
|
(v) {
|
||||||
|
@ -77,7 +76,6 @@ class _ProfileWrapperState extends State<ProfileWrapper> {
|
||||||
defaultItems.add(
|
defaultItems.add(
|
||||||
builder.build(
|
builder.build(
|
||||||
'last_name',
|
'last_name',
|
||||||
formKey,
|
|
||||||
widget.user.lastName,
|
widget.user.lastName,
|
||||||
null,
|
null,
|
||||||
(v) {
|
(v) {
|
||||||
|
@ -96,7 +94,6 @@ class _ProfileWrapperState extends State<ProfileWrapper> {
|
||||||
defaultItems.add(
|
defaultItems.add(
|
||||||
widget.itemBuilder!.build(
|
widget.itemBuilder!.build(
|
||||||
'first_name',
|
'first_name',
|
||||||
formKey,
|
|
||||||
widget.user.firstName,
|
widget.user.firstName,
|
||||||
null,
|
null,
|
||||||
(v) {
|
(v) {
|
||||||
|
@ -114,7 +111,6 @@ class _ProfileWrapperState extends State<ProfileWrapper> {
|
||||||
defaultItems.add(
|
defaultItems.add(
|
||||||
widget.itemBuilder!.build(
|
widget.itemBuilder!.build(
|
||||||
'last_name',
|
'last_name',
|
||||||
formKey,
|
|
||||||
widget.user.lastName,
|
widget.user.lastName,
|
||||||
null,
|
null,
|
||||||
(v) {
|
(v) {
|
Loading…
Reference in a new issue