UiStateBuilder<T> class
final
A reactive widget that builds different UI states based on UiStateModel.
This widget listens to a reactive Rx<UiStateModel>
and renders one of the following states:
initial
: Shows a placeholder UI.loading
: Shows a loading indicator.empty
: Shows an empty state view.success
: Shows the main UI using the builder.error
: Shows an error UI with optional retry.
It supports global fallback widgets configured via GlobalUiStateConfig, and also allows per-instance overrides for flexibility.
⚠️ Make sure to call GlobalUiStateConfig.initialize in your main.dart
before using this widget, otherwise an assertion will fail.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatelessWidget
- UiStateBuilder
Constructors
-
UiStateBuilder.new({required Rx<
UiStateModel< uiStateModel, required Widget builder(BuildContext context, T data), Widget? initialOverride, Widget? loadingOverride, Widget? emptyOverride, Widget errorBuilderOverride(BuildContext context, String error)?, bool isRetry = false, VoidCallback? retryFunction, Key? key})T> >
Properties
- builder → Widget Function(BuildContext context, T data)
-
The builder function to construct the success UI when data is available.
final
- emptyOverride → Widget?
-
Optional widget to override the global empty state widget.
final
- errorBuilderOverride → Widget Function(BuildContext context, String error)?
-
Optional error widget builder to override the global error builder.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- initialOverride → Widget?
-
Optional widget to override the global initial state widget.
final
- isRetry → bool
-
Whether to show a retry mechanism for this screen (optional, used with global retry config).
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- loadingOverride → Widget?
-
Optional widget to override the global loading state widget.
final
- retryFunction → VoidCallback?
-
Retry callback specific to this screen (overrides global retry if provided).
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
uiStateModel
→ Rx<
UiStateModel< T> > -
The reactive state model to observe.
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.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent 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 -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → 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.
inherited