StateBuilder<B extends BaseBloc, S extends BlocState> class

Built upon BlocBuilder class Can be used for building a widget on a specific bloc state

Note: You don't need to use the StateBuilder directly (although you can), most of the times (even always), you should use ComponentView.stateBuilder method instead.


StateBuilder<MyBloc, MyState>(
  builder: (context, state) => onState(...)

The state builder knows to handle loading and error states. Each state that extends StateLoading will be considered as loading state, and the onLoading callback will be called for it. And each state that extends StateError will be considered as error state, and the onError state will be called for it



StateBuilder({@required BlocWidgetBuilder<S> builder, B bloc, BlocBuilderCondition<BlocState> condition, BlocWidgetBuilder<StateLoading> onLoading, BlocWidgetBuilder<StateError> onError, BlocWidgetBuilder<BlocState> onOther, bool skipError: false, bool skipLoading: false})


bloc → B
The bloc to interact with. If not provided, it will be searched in the BuildContext. See BlocBuilderBase.bloc
builder BlocWidgetBuilder<S>
Builder that will be called on when the state is S See BlocBuilder.builder
condition BlocBuilderCondition<BlocState>
Condition for calling the builder. Same as in BlocBuilder. Usually You don't need to override it. It will be automatically calculated according to the success, loading and error states. For more info about condition, see BlocBuilderBase.condition
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
onError BlocWidgetBuilder<StateError>
The builder that will be called on any error state that extends StateError
onLoading BlocWidgetBuilder<StateLoading>
The builder that will be called on any loading state that extends StateLoading
onOther BlocWidgetBuilder<BlocState>
The builder tha will be called on any other state that is not S, StateLoading or StateError
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
skipError bool
Set it to true if you don't want to handle error state (your widget won't be rebuilt on error states that extend StateError).
skipLoading bool
Set it to true if you don't want to handle loading state (your widget won't be rebuilt on loading states that extend StateLoading)


build(BuildContext context) Widget
Describes the part of the user interface represented by this widget. [...]
createElement() StatelessElement
Creates a StatelessElement to manage this widget's location in the tree. [...]
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. [...]
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
toDiagnosticsNode({String name, DiagnosticsTreeStyle style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep. [...]
toString({DiagnosticLevel minLevel:}) String
Returns a string representation of this object.
toStringDeep({String prefixLineOne: '', String prefixOtherLines, DiagnosticLevel minLevel: DiagnosticLevel.debug}) String
Returns a string representation of this node and its descendants. [...]
toStringShallow({String joiner: ', ', DiagnosticLevel minLevel: DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object. [...]
toStringShort() String
A short, textual description of this widget.


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

Static Properties

builderConfig StateBuilderConfig
Builder config. Can be overridden simply by settings it to a new implementation of StateBuilderConfig
read / write