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 :

Constructors

InjectedForm()

Properties

autoDisposeWhenNotUsed bool
no setterinherited
autovalidateMode AutovalidateMode
Used to enable/disable this form field auto validation and update its error text.
getter/setter pair
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 observers
no setterinherited
isActive bool
Whether the state is active or not.
no setterinherited
isDirty bool
no setter
isDone bool
The state is mutated using a stream and the stream is done.
no setterinherited
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
oldSnapState SnapState<bool?>
no setterinherited
rebuild → _RebuildForm
Listen to the InjectedForm and rebuild when it is notified.
latefinal
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
snapState SnapState<bool?>
A snap representation of the state
getter/setter pairinherited
state bool?
no setterinherited
stateAsync Future<bool?>
It is a future of the state. The future is active if the state is on the isWaiting status.
no setterinherited
submitFocusNode FocusNode
Creates a focus node to be used with submit button
no setter

Methods

dispose() → void
Dispose the state.
inherited
initializeState() FutureOr<bool?>
Initialize the state
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notify() → void
Notify observers
inherited
onAll<R>({R onIdle()?, required R onWaiting()?, required R onError(dynamic error, VoidCallback refreshError)?, required R onData(bool? data)}) → R
inherited
onOrElse<R>({R onIdle()?, R onWaiting()?, R onError(dynamic error, VoidCallback refreshError)?, R onData(bool? data)?, required R orElse(bool? data)}) → R
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