mirror of
https://github.com/Iconica-Development/flutter_profile.git
synced 2025-05-19 01:03:45 +02:00
Merge pull request #7 from Iconica-Development/hotfix/single-form
single form
This commit is contained in:
commit
6e3b69d5d0
2 changed files with 6 additions and 15 deletions
|
@ -8,6 +8,7 @@ class ItemList extends StatefulWidget {
|
|||
this.typeMap,
|
||||
this.spacing,
|
||||
this.updateProfile, {
|
||||
required this.formKey,
|
||||
this.itemBuilder,
|
||||
this.itemBuilderOptions,
|
||||
super.key,
|
||||
|
@ -19,25 +20,13 @@ class ItemList extends StatefulWidget {
|
|||
final Function(String, String) updateProfile;
|
||||
final ItemBuilder? itemBuilder;
|
||||
final ItemBuilderOptions? itemBuilderOptions;
|
||||
final GlobalKey<FormState> formKey;
|
||||
|
||||
@override
|
||||
State<ItemList> createState() => _ItemListState();
|
||||
}
|
||||
|
||||
class _ItemListState extends State<ItemList> {
|
||||
Map<String, GlobalKey<FormState>> formKeys = {};
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
for (var item in widget.items.entries) {
|
||||
formKeys.addAll(
|
||||
{item.key: GlobalKey<FormState>()},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var widgets = <Widget>[];
|
||||
|
@ -49,7 +38,7 @@ class _ItemListState extends State<ItemList> {
|
|||
? widgets.add(
|
||||
builder.build(
|
||||
item.key,
|
||||
formKeys['item.key'] ?? GlobalKey<FormState>(),
|
||||
widget.formKey,
|
||||
item.value,
|
||||
widget.typeMap[item.key],
|
||||
(value) {
|
||||
|
@ -60,7 +49,7 @@ class _ItemListState extends State<ItemList> {
|
|||
: widgets.add(
|
||||
widget.itemBuilder!.build(
|
||||
item.key,
|
||||
formKeys['item.key'] ?? GlobalKey<FormState>(),
|
||||
widget.formKey,
|
||||
item.value,
|
||||
widget.typeMap[item.key],
|
||||
(value) {
|
||||
|
|
|
@ -151,6 +151,7 @@ class _ProfileWrapperState extends State<ProfileWrapper> {
|
|||
},
|
||||
itemBuilder: widget.itemBuilder,
|
||||
itemBuilderOptions: widget.itemBuilderOptions,
|
||||
formKey: formKey,
|
||||
),
|
||||
if (widget.showDefaultItems) ...defaultItems,
|
||||
// remove all the items that have priority from the widget.user.profileData!.toMap()
|
||||
|
@ -169,6 +170,7 @@ class _ProfileWrapperState extends State<ProfileWrapper> {
|
|||
},
|
||||
itemBuilder: widget.itemBuilder,
|
||||
itemBuilderOptions: widget.itemBuilderOptions,
|
||||
formKey: formKey,
|
||||
),
|
||||
],
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue