StoreConnector<St, Model> class

Build a widget based on the state of the Store.

Before the builder is run, the converter will convert the store into a more specific Model tailored to the Widget being built.

Every time the store changes, the Widget will be rebuilt. As a performance optimization, the Widget can be rebuilt only when the Model changes. In order for this to work correctly, you must implement == and hashCode for the Model, and set the distinct option to true when creating your StoreConnector.

Inheritance
Implemented types

Constructors

StoreConnector({Key key, @required ViewModelBuilder<Model> builder, bool distinct, VmFactory vm, StoreConverter<St, Model> converter, BaseModel model, Object debug, OnInitCallback<St> onInit, OnDisposeCallback<St> onDispose, bool rebuildOnChange: true, ShouldUpdateModel<St> shouldUpdateModel, OnWillChangeCallback<Model> onWillChange, OnDidChangeCallback<Model> onDidChange, OnInitialBuildCallback<Model> onInitialBuild})
const

Properties

builder ViewModelBuilder<Model>
Build a Widget using the BuildContext and Model. The Model is created by the converter or model functions.
final
converter StoreConverter<St, Model>
Convert the Store into a Model. The resulting Model will be passed to the builder function.
final
debug Object
Pass the parameter debug: this to get a more detailed error message.
final
distinct bool
When distinct is true (the default), the Widget is rebuilt only when the Model changes. In order for this to work correctly, you must implement == and hashCode for the Model.
final
hashCode int
The hash code for this object. [...]
@nonVirtual, read-only, inherited
key Key
Controls how one widget replaces another widget in the tree. [...]
final, inherited
model BaseModel
Don't use, this is deprecated. Please, use the recommended vm parameter (of type VmFactory) or converter.
@Deprecated('Please, use `vm` parameter. ' 'See classes `VmFactory` and `Vm`.'), final
onDidChange OnDidChangeCallback<Model>
A function that will be run on State change, after the Widget is built. This function is passed the Model, and if distinct is true, it will only be called if the Model changes. This can be useful for running certain animations after the build is complete. Note: Using a BuildContext inside this callback can cause problems if the callback performs navigation. For navigation purposes, please use onWillChange.
final
onDispose OnDisposeCallback<St>
A function that will be run when the StoreConnector is removed from the Widget Tree. It is run in the State.dispose method. This can be useful for dispatching actions that remove stale data from your State tree.
final
onInit OnInitCallback<St>
A function that will be run when the StoreConnector is initially created. It is run in the State.initState method. This can be useful for dispatching actions that fetch data for your Widget when it is first displayed.
final
onInitialBuild OnInitialBuildCallback<Model>
A function that will be run after the Widget is built the first time. This function is passed the initial Model created by the converter or vm function. This can be useful for starting certain animations, such as showing snackbars, after the Widget is built the first time.
final
onWillChange OnWillChangeCallback<Model>
A function that will be run on State change, before the Widget is built. This function is passed the Model, and if distinct is true, it will only be called if the Model changes. This can be useful for imperative calls to things like Navigator, TabController, etc
final
rebuildOnChange bool
Determines whether the Widget should be rebuilt when the Store emits an onChange event.
final
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
shouldUpdateModel ShouldUpdateModel<St>
A test of whether or not your vm or converter function should run in response to a State change. For advanced use only. Some changes to the State of your application will mean your vm or converter function can't produce a useful Model. In these cases, such as when performing exit animations on data that has been removed from your Store, it can be best to ignore the State change while your animation completes. To ignore a change, provide a function that returns true or false. If the returned value is true, the change will be applied. If the returned value is false, the change will be ignored. If you ignore a change, and the framework needs to rebuild the Widget, the builder function will be called with the latest Model produced by your vm or converter function.
final
vm VmFactory
Convert the Store into a Model. The resulting Model will be passed to the builder function.
final

Methods

build(BuildContext context) Widget
Describes the part of the user interface represented by this widget. [...]
override
createElement() StatelessElement
Creates a StatelessElement to manage this widget's location in the tree. [...]
inherited
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children. [...]
@protected, inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node. [...]
inherited
getLatestModel(Store store) → Model
This is not used directly by the store, but may be used in tests. If you have a store and a StoreConnector, and you want its associated ViewModel, you can do: Model viewModel = storeConnector.getLatestModel(store); [...]
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
toDiagnosticsNode({String name, DiagnosticsTreeStyle style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep. [...]
inherited
toString({DiagnosticLevel minLevel: DiagnosticLevel.info}) String
Returns a string representation of this object.
inherited
toStringDeep({String prefixLineOne: '', String prefixOtherLines, DiagnosticLevel minLevel: DiagnosticLevel.debug}) String
Returns a string representation of this node and its descendants. [...]
inherited
toStringShallow({String joiner: ', ', DiagnosticLevel minLevel: DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object. [...]
inherited
toStringShort() String
A short, textual description of this widget.
inherited

Operators

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