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