InjectedTextEditing class Null safety

Inject a TextEditingController

This injected state abstracts the best practices to come out with a simple, clean, and testable approach deal with TextField and form validation.

The approach consists of the following steps:

     final email =  RM.injectTextEditing():
  • Instantiate an InjectedTextEditing object using RM.injectTextEditing
  • Link the injected state to a TextField (No need to TextFormField even inside a OnFormBuilder).
       TextField(
          controller: email.controller,
          focusNode: email.focusNode, //It is auto disposed of.
          decoration:  InputDecoration(
              errorText: email.error, //To display the error message.
          ),
          onSubmitted: (_) {
              //Focus on the password TextField after submission
              password.focusNode.requestFocus();
          },
      ),
    

See also :

Constructors

InjectedTextEditing()

Properties

autoDisposeWhenNotUsed bool
read-only, inherited
composing TextRange
The range of text that is still being composed.
read-only
controller → TextEditingControllerImp
A controller for an editable text field.
read-only
error ↔ dynamic
The error
read / write, inherited-getter
focusNode FocusNode
Creates a focus node for this TextField
read-only
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
isEnabled bool
If false the associated TextField is disabled. [...]
read / write
isIdle bool
The state is initialized and never mutated.
read-only, inherited
isReadOnly bool
If true the TextField is clickable, selectable and focusable but not editable. [...]
read / write
isValid bool
Whether it passes the validation test
read-only
isWaiting bool
The state is waiting for and asynchronous task to end.
read-only, inherited
oldSnapState SnapState<String>
read-only, inherited
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
selection TextSelection
The range of text that is currently selected.
read-only
snapState SnapState<String>
A snap representation of the state
read / write, inherited
state String
read-only, inherited
stateAsync Future<String>
It is a future of the state. The future is active if the state is on the isWaiting status.
read-only, inherited
text String
The current text being edited.
read-only
value String
read-only

Methods

dispose() → void
Dispose the state.
inherited
initializeState() FutureOr<String>
Initialize the state
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent 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(String data)}) → R
inherited
onOrElse<R>({R onIdle()?, R onWaiting()?, R onError(dynamic error, VoidCallback refreshError)?, R onData(String data)?, required R orElse(String data)}) → R
inherited
reset() → void
toString() String
A string representation of this object. [...]
inherited
validate() bool
Invoke field validators and return true if the field is valid.

Operators

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