mirror of
https://github.com/Iconica-Development/flutter_profile.git
synced 2025-05-19 01:03:45 +02:00
Compare commits
8 commits
Author | SHA1 | Date | |
---|---|---|---|
eda3a928cd | |||
|
3c95ad2c3f | ||
8d3be0083a | |||
|
91735f40cd | ||
|
2e0fcb50c0 | ||
|
9374ea9694 | ||
|
d6ab8e4218 | ||
|
6393eda1c1 |
8 changed files with 43 additions and 48 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -38,3 +38,7 @@ example/web/
|
|||
.flutter-plugins
|
||||
.flutter-plugins-dependencies
|
||||
.metadata
|
||||
|
||||
# FVM Version Cache
|
||||
.fvm/
|
||||
.fvmrc
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
## 1.6.0
|
||||
* Upgraded flutter_input_library to 3.6.0
|
||||
|
||||
## 1.5.0
|
||||
|
||||
- Updated flutter_input_library to 3.2.1
|
||||
|
|
|
@ -17,7 +17,7 @@ class ExampleProfileData extends ProfileData {
|
|||
String? remarks;
|
||||
|
||||
@override
|
||||
Map<String, dynamic> mapWidget(
|
||||
Map<String, Widget?> mapWidget(
|
||||
VoidCallback update,
|
||||
BuildContext context,
|
||||
) {
|
||||
|
@ -38,7 +38,7 @@ class ExampleProfileData extends ProfileData {
|
|||
}
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toMap() {
|
||||
Map<String, String?> toMap() {
|
||||
return {'email': email, 'about': about, 'remarks': remarks};
|
||||
}
|
||||
|
||||
|
|
|
@ -76,9 +76,9 @@ abstract class ProfileData {
|
|||
|
||||
ProfileData fromMap(Map<String, dynamic> data);
|
||||
|
||||
Map<String, dynamic> toMap();
|
||||
Map<String, String?> toMap();
|
||||
|
||||
Map<String, dynamic> mapWidget(VoidCallback update, BuildContext context);
|
||||
Map<String, Widget?> mapWidget(VoidCallback update, BuildContext context);
|
||||
|
||||
ProfileData create();
|
||||
}
|
||||
|
|
|
@ -21,8 +21,8 @@ class ItemBuilder {
|
|||
String key,
|
||||
String? value,
|
||||
Widget? widget,
|
||||
Function(String) updateItem,
|
||||
Function(String?) saveItem,
|
||||
void Function(String) updateItem,
|
||||
void Function(String?) saveItem,
|
||||
) {
|
||||
if (widget == null) {
|
||||
var controller = TextEditingController(
|
||||
|
@ -55,7 +55,7 @@ class ItemBuilder {
|
|||
Widget buildPassword(
|
||||
String key,
|
||||
TextEditingController controller,
|
||||
Function(String?) onChanged,
|
||||
void Function(String?) onChanged,
|
||||
String? Function(String?) validator,
|
||||
) {
|
||||
var inputDecoration =
|
||||
|
|
|
@ -16,49 +16,39 @@ class ItemList {
|
|||
this.itemBuilder,
|
||||
this.itemBuilderOptions,
|
||||
}) {
|
||||
for (var item in items.entries) {
|
||||
widgets.addAll({
|
||||
item.key: itemBuilder == null
|
||||
? builder.build(
|
||||
item.key,
|
||||
item.value,
|
||||
typeMap[item.key],
|
||||
(value) {
|
||||
saveProfile();
|
||||
},
|
||||
(value) {
|
||||
updateProfile(item.key, value);
|
||||
},
|
||||
)
|
||||
: itemBuilder!.build(
|
||||
item.key,
|
||||
item.value,
|
||||
typeMap[item.key],
|
||||
(value) {
|
||||
saveProfile();
|
||||
},
|
||||
(value) {
|
||||
updateProfile(item.key, value);
|
||||
},
|
||||
),
|
||||
});
|
||||
}
|
||||
var itemBuilder = this.itemBuilder ?? builder;
|
||||
|
||||
widgets = {
|
||||
for (var item in items.entries) ...{
|
||||
item.key: itemBuilder.build(
|
||||
item.key,
|
||||
item.value,
|
||||
typeMap[item.key],
|
||||
(value) {
|
||||
saveProfile();
|
||||
},
|
||||
(value) {
|
||||
updateProfile(item.key, value);
|
||||
},
|
||||
),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/// Gets the map of item keys and their corresponding widgets.
|
||||
Map<String, Widget> getItemList() => widgets;
|
||||
|
||||
/// Map containing item keys and their values.
|
||||
final Map<String, dynamic> items;
|
||||
final Map<String, String?> items;
|
||||
|
||||
/// Map containing item keys and their types.
|
||||
final Map<String, dynamic> typeMap;
|
||||
final Map<String, Widget?> typeMap;
|
||||
|
||||
/// Function to update the profile with a specific item's value.
|
||||
final Function(String, String?) updateProfile;
|
||||
final void Function(String, String?) updateProfile;
|
||||
|
||||
/// Function to save the profile after an item value is updated.
|
||||
final Function() saveProfile;
|
||||
final void Function() saveProfile;
|
||||
|
||||
/// Builder for custom item widgets.
|
||||
final ItemBuilder? itemBuilder;
|
||||
|
@ -70,7 +60,7 @@ class ItemList {
|
|||
final GlobalKey<FormState> formKey;
|
||||
|
||||
/// Map containing item keys and their corresponding widgets.
|
||||
Map<String, Widget> widgets = {};
|
||||
late final Map<String, Widget> widgets;
|
||||
|
||||
/// `builder` is an instance of `ItemBuilder` which is used
|
||||
/// to build the items in the list.
|
||||
|
|
12
pubspec.yaml
12
pubspec.yaml
|
@ -1,21 +1,19 @@
|
|||
name: flutter_profile
|
||||
description: Flutter profile package
|
||||
version: 1.5.1
|
||||
version: 1.6.0
|
||||
repository: https://github.com/Iconica-Development/flutter_profile
|
||||
|
||||
publish_to: none
|
||||
publish_to: https://forgejo.internal.iconica.nl/api/packages/internal/pub
|
||||
|
||||
environment:
|
||||
sdk: ^3.0.0
|
||||
sdk: ">=3.0.0 <4.0.0"
|
||||
flutter: ">=1.17.0"
|
||||
|
||||
dependencies:
|
||||
cached_network_image: ^3.3.0
|
||||
|
||||
flutter_input_library:
|
||||
git:
|
||||
url: https://github.com/Iconica-Development/flutter_input_library
|
||||
ref: 3.3.1
|
||||
hosted: https://forgejo.internal.iconica.nl/api/packages/internal/pub
|
||||
version: ^3.6.0
|
||||
|
||||
flutter:
|
||||
sdk: flutter
|
||||
|
|
|
@ -13,7 +13,7 @@ class TestProfileData extends ProfileData {
|
|||
String? email;
|
||||
|
||||
@override
|
||||
Map<String, dynamic> mapWidget(
|
||||
Map<String, Widget?> mapWidget(
|
||||
VoidCallback update,
|
||||
BuildContext context,
|
||||
) =>
|
||||
|
@ -27,7 +27,7 @@ class TestProfileData extends ProfileData {
|
|||
);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toMap() => {
|
||||
Map<String, String?> toMap() => {
|
||||
'email': email,
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue