diff --git a/CHANGELOG.md b/CHANGELOG.md
index f8589a9..dd90266 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,4 +8,8 @@
## 0.0.3
-* Add support for image URL (instead of in-memory image using image parameter from User model)
\ No newline at end of file
+* Add support for image URL (instead of in-memory image using image parameter from User model)
+
+## 0.0.7
+
+* Submit all edited fields on submit of one field
\ No newline at end of file
diff --git a/example/.metadata b/example/.metadata
index 39f2501..02bbd38 100644
--- a/example/.metadata
+++ b/example/.metadata
@@ -4,7 +4,7 @@
# This file should be version controlled.
version:
- revision: f1875d570e39de09040c8f79aa13cc56baab8db1
+ revision: 52b3dc25f6471c27b2144594abb11c741cb88f57
channel: stable
project_type: app
@@ -13,26 +13,23 @@ project_type: app
migration:
platforms:
- platform: root
- create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
- base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
+ create_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57
+ base_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57
- platform: android
- create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
- base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
+ create_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57
+ base_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57
- platform: ios
- create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
- base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
+ create_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57
+ base_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57
- platform: linux
- create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
- base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
+ create_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57
+ base_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57
- platform: macos
- create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
- base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
+ create_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57
+ base_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57
- platform: web
- create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
- base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
- - platform: windows
- create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
- base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
+ create_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57
+ base_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57
# User provided section
diff --git a/example/pubspec.lock b/example/pubspec.lock
index 9a64588..9d04e66 100644
--- a/example/pubspec.lock
+++ b/example/pubspec.lock
@@ -68,7 +68,7 @@ packages:
path: ".."
relative: true
source: path
- version: "0.0.2"
+ version: "0.0.9"
flutter_test:
dependency: "direct dev"
description: flutter
diff --git a/example/pubspec.yaml b/example/pubspec.yaml
index f1d5956..40fb165 100644
--- a/example/pubspec.yaml
+++ b/example/pubspec.yaml
@@ -58,7 +58,6 @@ flutter:
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true
-
# To add assets to your application, add an assets section, like this:
# assets:
# - images/a_dot_burr.jpeg
diff --git a/example/test/widget_test.dart b/example/test/widget_test.dart
new file mode 100644
index 0000000..20ff593
--- /dev/null
+++ b/example/test/widget_test.dart
@@ -0,0 +1,14 @@
+// This is a basic Flutter widget test.
+//
+// To perform an interaction with a widget in your test, use the WidgetTester
+// utility in the flutter_test package. For example, you can send tap and scroll
+// gestures. You can also use WidgetTester to find child widgets in the widget
+// tree, read text, and verify that the values of widget properties are correct.
+
+import 'package:flutter_test/flutter_test.dart';
+
+void main() {
+ test('', () {
+ expect(true, isTrue);
+ });
+}
diff --git a/example/web/favicon.png b/example/web/favicon.png
deleted file mode 100644
index 8aaa46a..0000000
Binary files a/example/web/favicon.png and /dev/null differ
diff --git a/example/web/icons/Icon-192.png b/example/web/icons/Icon-192.png
deleted file mode 100644
index b749bfe..0000000
Binary files a/example/web/icons/Icon-192.png and /dev/null differ
diff --git a/example/web/icons/Icon-512.png b/example/web/icons/Icon-512.png
deleted file mode 100644
index 88cfd48..0000000
Binary files a/example/web/icons/Icon-512.png and /dev/null differ
diff --git a/example/web/icons/Icon-maskable-192.png b/example/web/icons/Icon-maskable-192.png
deleted file mode 100644
index eb9b4d7..0000000
Binary files a/example/web/icons/Icon-maskable-192.png and /dev/null differ
diff --git a/example/web/icons/Icon-maskable-512.png b/example/web/icons/Icon-maskable-512.png
deleted file mode 100644
index d69c566..0000000
Binary files a/example/web/icons/Icon-maskable-512.png and /dev/null differ
diff --git a/example/web/index.html b/example/web/index.html
deleted file mode 100644
index 41b3bc3..0000000
--- a/example/web/index.html
+++ /dev/null
@@ -1,58 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- example
-
-
-
-
-
-
-
-
-
-
diff --git a/example/web/manifest.json b/example/web/manifest.json
deleted file mode 100644
index 096edf8..0000000
--- a/example/web/manifest.json
+++ /dev/null
@@ -1,35 +0,0 @@
-{
- "name": "example",
- "short_name": "example",
- "start_url": ".",
- "display": "standalone",
- "background_color": "#0175C2",
- "theme_color": "#0175C2",
- "description": "A new Flutter project.",
- "orientation": "portrait-primary",
- "prefer_related_applications": false,
- "icons": [
- {
- "src": "icons/Icon-192.png",
- "sizes": "192x192",
- "type": "image/png"
- },
- {
- "src": "icons/Icon-512.png",
- "sizes": "512x512",
- "type": "image/png"
- },
- {
- "src": "icons/Icon-maskable-192.png",
- "sizes": "192x192",
- "type": "image/png",
- "purpose": "maskable"
- },
- {
- "src": "icons/Icon-maskable-512.png",
- "sizes": "512x512",
- "type": "image/png",
- "purpose": "maskable"
- }
- ]
-}
diff --git a/lib/src/widgets/item_builder/item_builder.dart b/lib/src/widgets/item_builder/item_builder.dart
index 2d73a8a..c76c740 100644
--- a/lib/src/widgets/item_builder/item_builder.dart
+++ b/lib/src/widgets/item_builder/item_builder.dart
@@ -15,8 +15,8 @@ class ItemBuilder {
final ItemBuilderOptions options;
- Widget build(
- String key, dynamic value, Widget? widget, Function(String) updateItem) {
+ Widget build(String key, dynamic value, Widget? widget,
+ Function(String) updateItem, Function(String) saveItem) {
if (widget == null) {
var controller = TextEditingController(
text: '${value ?? ''}',
@@ -38,6 +38,11 @@ class ItemBuilder {
updateItem(value);
}
},
+ onSaved: (newValue) {
+ if (newValue != null && newValue != value) {
+ saveItem(newValue);
+ }
+ },
validator: (value) {
return options.validators?[key]?.call(value);
},
diff --git a/lib/src/widgets/item_builder/item_list.dart b/lib/src/widgets/item_builder/item_list.dart
index 85abc48..12e71e0 100644
--- a/lib/src/widgets/item_builder/item_list.dart
+++ b/lib/src/widgets/item_builder/item_list.dart
@@ -11,7 +11,8 @@ class ItemList extends StatefulWidget {
this.items,
this.typeMap,
this.spacing,
- this.updateProfile, {
+ this.updateProfile,
+ this.saveProfile, {
required this.formKey,
this.itemBuilder,
this.itemBuilderOptions,
@@ -22,6 +23,7 @@ class ItemList extends StatefulWidget {
final Map typeMap;
final double spacing;
final Function(String, String) updateProfile;
+ final Function() saveProfile;
final ItemBuilder? itemBuilder;
final ItemBuilderOptions? itemBuilderOptions;
final GlobalKey formKey;
@@ -44,6 +46,9 @@ class _ItemListState extends State {
item.key,
item.value,
widget.typeMap[item.key],
+ (value) {
+ widget.saveProfile();
+ },
(value) {
widget.updateProfile(item.key, value);
},
@@ -54,6 +59,9 @@ class _ItemListState extends State {
item.key,
item.value,
widget.typeMap[item.key],
+ (value) {
+ widget.saveProfile();
+ },
(value) {
widget.updateProfile(item.key, value);
},
diff --git a/lib/src/widgets/profile/profile_wrapper.dart b/lib/src/widgets/profile/profile_wrapper.dart
index bebcebc..faf9d90 100644
--- a/lib/src/widgets/profile/profile_wrapper.dart
+++ b/lib/src/widgets/profile/profile_wrapper.dart
@@ -13,7 +13,6 @@ import 'package:flutter_profile/src/widgets/profile/profile_style.dart';
class ProfileWrapper extends StatefulWidget {
const ProfileWrapper({
- Key? key,
required this.user,
required this.service,
required this.rebuild,
@@ -26,7 +25,8 @@ class ProfileWrapper extends StatefulWidget {
this.prioritizedItems = const [],
this.showDefaultItems = true,
this.wrapItemsBuilder,
- }) : super(key: key);
+ super.key,
+ });
final User user;
final ProfileService service;
@@ -51,11 +51,11 @@ class _ProfileWrapperState extends State {
List defaultItems = [];
GlobalKey formKey = GlobalKey();
+ Map formValues = {};
@override
void initState() {
super.initState();
-
if (widget.itemBuilder == null) {
ItemBuilder builder = ItemBuilder(
options: widget.itemBuilderOptions ?? ItemBuilderOptions(),
@@ -65,9 +65,11 @@ class _ProfileWrapperState extends State {
'first_name',
widget.user.firstName,
null,
+ (value) {
+ submitAllChangedFields();
+ },
(v) {
widget.user.firstName = v;
-
widget.service.editProfile(widget.user, 'first_name', v);
},
),
@@ -82,9 +84,11 @@ class _ProfileWrapperState extends State {
'last_name',
widget.user.lastName,
null,
+ (value) {
+ submitAllChangedFields();
+ },
(v) {
widget.user.lastName = v;
-
widget.service.editProfile(widget.user, 'last_name', v);
},
),
@@ -100,9 +104,11 @@ class _ProfileWrapperState extends State {
'first_name',
widget.user.firstName,
null,
+ (value) {
+ submitAllChangedFields();
+ },
(v) {
widget.user.firstName = v;
-
widget.service.editProfile(widget.user, 'first_name', v);
},
),
@@ -117,9 +123,11 @@ class _ProfileWrapperState extends State {
'last_name',
widget.user.lastName,
null,
+ (value) {
+ submitAllChangedFields();
+ },
(v) {
widget.user.lastName = v;
-
widget.service.editProfile(widget.user, 'last_name', v);
},
),
@@ -149,6 +157,9 @@ class _ProfileWrapperState extends State {
(key, value) {
widget.service.editProfile(widget.user, key, value);
},
+ () {
+ submitAllChangedFields();
+ },
itemBuilder: widget.itemBuilder,
itemBuilderOptions: widget.itemBuilderOptions,
formKey: formKey,
@@ -168,6 +179,9 @@ class _ProfileWrapperState extends State {
(key, value) {
widget.service.editProfile(widget.user, key, value);
},
+ () {
+ submitAllChangedFields();
+ },
itemBuilder: widget.itemBuilder,
itemBuilderOptions: widget.itemBuilderOptions,
formKey: formKey,
@@ -223,4 +237,11 @@ class _ProfileWrapperState extends State {
),
);
}
+
+ /// This calls onSaved on all the fiels which check if they have a new value
+ void submitAllChangedFields() {
+ if (formKey.currentState!.validate()) {
+ formKey.currentState!.save();
+ }
+ }
}
diff --git a/pubspec.yaml b/pubspec.yaml
index 9004e6a..6ddf4a2 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,6 +1,6 @@
name: flutter_profile
description: Flutter profile package
-version: 0.0.2
+version: 0.0.9
repository: https://github.com/Iconica-Development/flutter_profile
environment: