PrismStateView<T> class
Renders one widget for all four async UI states: loading, error, empty, and success — with built-in retry and smart defaults.
PrismStateView<String>(
state: viewState, // a PrismViewState<String>
emptyMessage: 'No items yet',
onRetry: () => refetch(),
successBuilder: (data) => ListView(children: [
for (final item in data) ListTile(title: Text(item)),
]),
)
Because PrismViewState is sealed, Dart 3's exhaustiveness checking guarantees the switch inside this widget covers every state — and your code gets the same guarantee when you switch on it yourself.
Pure Flutter — no platform channels — works on Android, iOS, macOS, Windows, Linux, and web.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatelessWidget
- PrismStateView
Constructors
-
PrismStateView({Key? key, required PrismViewState<
T> state, required Widget successBuilder(T data), PrismStateViewStyle? style, String? loadingMessage, String? errorMessage, String? emptyMessage, String? emptyActionLabel, VoidCallback? onEmptyAction, VoidCallback? onRetry, IconData? loadingIcon, IconData? errorIcon, IconData? emptyIcon}) -
Creates a state-driven view.
const
Properties
- emptyActionLabel → String?
-
Label for the optional empty-state action button.
final
- emptyIcon → IconData?
-
Overrides the empty-state icon.
final
- emptyMessage → String?
-
Overrides the default empty text.
final
- errorIcon → IconData?
-
Overrides the error icon.
final
- errorMessage → String?
-
Overrides the default error text.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- loadingIcon → IconData?
-
Overrides the loading indicator icon.
final
- loadingMessage → String?
-
Overrides the default loading text.
final
- onEmptyAction → VoidCallback?
-
Callback for the empty-state action button.
final
- onRetry → VoidCallback?
-
Called when the user taps "Retry" on an error state.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
state
→ PrismViewState<
T> -
The current view state.
final
- style → PrismStateViewStyle?
-
Visual configuration.
final
- successBuilder → Widget Function(T data)
-
Builds the real UI when PrismViewSuccess holds data.
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