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.

Example:

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

Inheritance

Constructors

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})

Properties

bloc → B
The bloc to interact with. If not provided, it will be searched in the BuildContext. See BlocBuilderBase.bloc
final
builder BlocWidgetBuilder<S>
Builder that will be called on when the state is S See BlocBuilder.builder
final
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
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
onError BlocWidgetBuilder<StateError>
The builder that will be called on any error state that extends StateError
final
onLoading BlocWidgetBuilder<StateLoading>
The builder that will be called on any loading state that extends StateLoading
final
onOther BlocWidgetBuilder<BlocState>
The builder tha will be called on any other state that is not S, StateLoading or StateError
final
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).
final
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)
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
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

Static Properties

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