InjectedForm class Null safety

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 :




autoDisposeWhenNotUsed bool
read-only, inherited
autovalidateMode AutovalidateMode
Used to enable/disable this form field auto validation and update its error text. [...]
read / write
error → dynamic
The error
read-only, inherited
hasData bool
The state is mutated successfully.
read-only, inherited
hasError bool
The stats has error
read-only, inherited
hashCode int
The hash code for this object. [...]
read-only, inherited
hasObservers bool
Whether the state has observers
read-only, inherited
isActive bool
Whether the state is active or not. [...]
read-only, inherited
isDone bool
The state is mutated using a stream and the stream is done.
read-only, inherited
isIdle bool
The state is initialized and never mutated.
read-only, inherited
isValid bool
True if all text fields of the form are valid.
isWaiting bool
The state is waiting for and asynchronous task to end.
read-only, inherited
oldSnapState SnapState<bool?>
read-only, inherited
rebuild → _RebuildForm
Listen to the InjectedForm and rebuild when it is notified.
late, final
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
snapState SnapState<bool?>
A snap representation of the state
read / write, inherited
state bool?
read-only, inherited
stateAsync Future<bool?>
It is a future of the state. The future is active if the state is on the isWaiting status.
read-only, inherited
submitFocusNode FocusNode
Creates a focus node to be used with submit button


dispose() → void
Dispose the state.
initializeState() FutureOr<bool?>
Initialize the state
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
notify() → void
Notify observers
onAll<R>({R onIdle()?, required R onWaiting()?, required R onError(dynamic error, VoidCallback refreshError)?, required R onData(bool? data)}) → R
onOrElse<R>({R onIdle()?, R onWaiting()?, R onError(dynamic error, VoidCallback refreshError)?, R onData(bool? data)?, required R orElse(bool? data)}) → R
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. [...]
validate() bool
Validate the text fields and return true if they are all valid


operator ==(Object other) bool
The equality operator. [...]