editable_model_form

Last updated:

0 purchases

editable_model_form Image
editable_model_form Images
Add to Cart

Description:

editable model form

Make a simple form that can switch between editable and not editable mode from a simple class model.
Features #
Show a form that can be editable or not editable from a simple class model.
Act on result of the submitting the form.
No need to write a lot of code to make a simple form.
Usage #
Create a model class that extends from EditableModel.
class ForgetPasswordFormModel extends EditableModel<ForgetPasswordFormModel> {
final String email;

ForgetPasswordFormModel({required this.email});

ForgetPasswordFormModel.fromJson(Map<String, Object?>? json)
: this(
email: json.getValueOr(
name: 'email',
defaultValue: "",
),
);

@override
ForgetPasswordFormModel fromEditJson(Map<String, dynamic> json) =>
ForgetPasswordFormModel.fromJson(json);

@override
List<FormViewType> getFormViewTypes() {
return [
FormEmailInputViewType(
key: "email",
label: "email:",
icon: const Icon(Icons.email),
defaultValue: email,
),
];
}

Map<String, Object?> toJson() {
return {
'email': email,
};
}
}
copied to clipboard
Create the form widget.
EditFormScreen<ForgetPasswordFormModel>(
title: "Enter your email address",
editableModel: ForgetPasswordFormModel(email: ""),
onSubmit: (result) {
debugPrint("onSubmit called. result:${result.toJson()}");

// Do the process of submitting the form here.

Navigator.pop(context);
},
).showInDialog(context: context, title: "Reset Password")
copied to clipboard

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.