InjectedTextEditing class abstract

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 :

Implemented types
Implementers

Constructors

InjectedTextEditing()

Properties

composing TextRange
The range of text that is still being composed.
no setter
controller TextEditingControllerImp
A controller for an editable text field.
no setter
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
getter/setter pairinherited-getter
focusNode FocusNode
Creates a focus node for this TextField
no setter
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
Whether the the value of the field is modified and not submitted yet;
no setter
isDone bool
The state is mutated using a stream and the stream is done.
no setterinherited
isEnabled bool
If false the associated TextField is disabled.
getter/setter pair
isIdle bool
The state is initialized and never mutated.
no setterinherited
isReadOnly bool
If true the TextField is clickable, selectable and focusable but not editable.
getter/setter pair
isValid bool
Whether it passes the validation test
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
selection TextSelection
The range of text that is currently selected.
no setter
snapState SnapState<String>
A snap representation of the state
no setterinherited
state String
no setter
text String
The current text being edited.
no setter
value String
Get the text of the field
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
controllerWithInitialText(String text) TextEditingControllerImp
Initializes a controller with the given initial text.
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
reset the text of the field
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