VmFactory<St, T> class
Factory that creates a view-model of type Vm, for the StoreConnector:
return StoreConnector<AppState, _ViewModel>(
vm: _Factory(),
builder: ...
You must override the fromStore method:
class _Factory extends VmFactory {
_ViewModel fromStore() => _ViewModel(
counter: state,
onIncrement: () => dispatch(IncrementAction(amount: 1)));
}
If necessary, you can pass the StoreConnector widget to the factory:
return StoreConnector<AppState, _ViewModel>(
vm: _Factory(this),
builder: ...
...
class _Factory extends VmFactory<AppState, MyHomePageConnector> {
_Factory(widget) : super(widget);
_ViewModel fromStore() => _ViewModel(
counter: state,
onIncrement: () => dispatch(IncrementAction(amount: widget.amount)));
}
Constructors
- VmFactory([T widget])
- You need to pass the connector widget only if the view-model needs any info from it.
Properties
-
dispatch
→ Dispatch<
St> -
read-only
-
dispatchFuture
→ DispatchFuture<
St> -
read-only
- hashCode → int
-
The hash code for this object. [...]
read-only, inherited
- runtimeType → Type
-
A representation of the runtime type of the object.
read-only, inherited
- state → St
-
The state the store was holding when the factory and the view-model were created.
This state is final inside of the factory.
read-only
- widget → T
-
A reference to the connector widget that will instantiate the view-model.
final
Methods
-
currentState(
) → St - The current (most recent) store state. This will return the current state the store holds at the time the method is called.
-
fromStore(
) → Vm -
getAndRemoveFirstError(
) → UserException -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a non-existent method or property is accessed. [...]
inherited
-
toString(
) → String -
Returns a string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator. [...]
inherited