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 :
- InjectedFormField for other type of inputs rather the text,
- InjectedForm and OnFormBuilder to work with form.
Constructors
Properties
- autoDisposeWhenNotUsed → bool
-
no setterinherited
- composing → TextRange
-
The range of text that is still being composed.
no setter
- controller → TextEditingControllerImp
-
A controller for an editable text field.
no setter
- 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 observers
no setterinherited
- isActive → bool
-
Whether the state is active 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
-
oldSnapState
→ SnapState<
String> -
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
getter/setter pairinherited
- state → String
-
no setterinherited
-
stateAsync
→ Future<
String> -
It is a future of the state. The future is active if the state is on the
isWaiting status.
no setterinherited
- text → String
-
The current text being edited.
no setter
- value → String
-
no setter
Methods
-
controllerWithInitialText(
String text) → TextEditingControllerImp - Initializes a controller with the given initial text.
-
dispose(
) → void -
Dispose the state.
inherited
-
initializeState(
) → FutureOr< String?> -
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(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