InjectedForm class abstract

Inject a form that controls all TextField and OnFormFieldBuilder instantiated inside its builder method.

If the application you are working on contains dozens of TextFields, it becomes tedious to process each field individually. Form helps us collect many TextFields and manage them as a unit.

With InjectedForm you can validate all input fields in the front end, submit them and do server side validation.

Example: Supposing we have already defined email and password InjectedTextEditing

 final form = RM.injectForm(
   submit: () async {
     //This is the default submission logic,
     //It may be override when calling form.submit( () async { });
     //It may contains server validation.
    await serverError =  authRepository.signInWithEmailAndPassword(
       email: email.text,
       password: password.text,
     );

     //after server validation
     if(serverError == 'Invalid-Email'){
       email.error = 'Invalid email';
     }
     if(serverError == 'Weak-Password'){
       email.error = 'Password must have more the 6 characters';
     }
   },
 );

Once InjectedForm.submit is invoked, input field are first validate in the front end. If they are valid, submit is called. After waiting for submission, if it ends with server error we set it our field to display the server validation.

See also :

Implemented types
Implementers
Available Extensions

Constructors

InjectedForm()

Properties

autovalidateMode AutovalidateMode
Listen to the InjectedForm and rebuild when it is notified. Used to enable/disable this form field auto validation and update its error text.
getter/setter pair
customStatus Object?
Custom status of the state. Set manually to mark the state with a particular tag to be used in your logic.
getter/setter pairinherited
error → dynamic
The error
no setterinherited
hasData bool
The state is mutated successfully.
no setterinherited
hasError bool
The stats has error
no setterinherited
hashCode int
The hash code for this object.
no setterinherited
hasObservers bool
Whether the state has listeners or not
no setterinherited
isDirty bool
Is the form dirty (At least on of its field has changed and the form not submitted yet)
no setter
isDone bool
The state is mutated using a stream and the stream is done.
no setterinherited
isFormEnabled bool
Whether form field are enabled or not.
getter/setter pair
isFormReadOnly bool
Whether form field are read only or not.
getter/setter pair
isIdle bool
The state is initialized and never mutated.
no setterinherited
isValid bool
True if all text fields of the form are valid.
no setter
isWaiting bool
The state is waiting for and asynchronous task to end.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
snapState SnapState<bool?>
A snap representation of the state
no setterinherited
submitFocusNode FocusNode
Creates a focus node to be used with submit button
no setter

Methods

addCleaner(VoidCallback listener) VoidCallback
Add a callback to be executed when the state is disposed of.
inherited
addObserver({required ObserveReactiveModel listener, bool shouldAutoClean = false, bool isSideEffects = true}) VoidCallback
Add observer to this state.
inherited
cleanState() → void
Clean the state
inherited
dispose() → void
Dispose the state
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notify() → void
Notify observers
inherited
reset() → void
Resets the fields to their initial values.
submit([Future<void> fn()?]) → void
Submit the form.
toString() String
A string representation of this object.
inherited
validate() bool
Validate the text fields and return true if they are all valid

Operators

operator ==(Object other) bool
The equality operator.
inherited