formly 1.0.1 formly: ^1.0.1 copied to clipboard
ease to create form
lets build form package (draft) (wip) #
user will write somethings like this
// should use marcos
@RiverForm()
class NameForm {
@StringItem<String>() // this may be optional and take it from datatype
external String name();
@PhoneTransformer<String>()
@PasswordValidator()
@PhoneValidator()
external String phone();
@PasswordValidator()
external String password();
@EqualField(#password) // password and confirmPassword should be equal
external String confirmPassword();
}
then he should use it like this
class MyWidget extends HookWidget {
const MyWidget({super.key});
@override
Widget build(BuildContext context) {
final form = useForm(NameForm());
return Form(
key: form.key,
child: Column(
children: [
TextFormField(
controller: form.name.controller,
validator: form.name.validator,
),
RiverText(form.name),
form.name.build(),
TextButton(
child: const Text("data"),
onPressed: () {
if (!form.validate()) {
return;
}
final result = form.result;
result.name;
result.phone;....
},
)
],
),
);
}
}
usecase:
Phase 1:
-
type safety first ✓
-
dropdown ✓
-
checklist ✓
-
option list ✓
-
validation ✓
-
ease dispose ✓
-
default value ✓
Phase 2:
- two password match
- multi select (array)
- ease pass data to other layer
- password obsecure
- complex validator for report multi error in password
- maybe step too
- integrate with hook
- phone transformer
Phase 3:
- marcos or code generation
- toJson or model
- ease widget builder