EasyStreamBuilder<T> class
A wrapper around StreamBuilder which makes it easy to display the various states of streaming data.
There are 4 possible states:
-
The snapshot is loading: --> shows the loadingIndicator.
-
The snapshot is loaded: --> shows the widget returned by the dataBuilder.
-
The snapshots data is loaded but empty (only works on Iterable/Map): --> shows SnapshotStateInfo with the isEmptyText and isEmptyIcon.
-
The snapshot has an error: --> shows SnapshotStateInfo with the errorText, errorIcon and the error message. NOTE: For safety reasons the snapshots error message is only shown in debug mode.
Have a look at the example to see this widget in action.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatelessWidget
- EasyStreamBuilder
Constructors
-
EasyStreamBuilder({Key? key, required Stream<
T> stream, required Widget dataBuilder(BuildContext context, T data), String errorText = 'Oops, something went wrong.', IconData errorIcon = Icons.error_rounded, String isEmptyText = 'There is nothing to display.', IconData isEmptyIcon = Icons.close_rounded, TextStyle? textStyle, IconThemeData? iconStyle, Widget loadingIndicator = const CircularProgressIndicator()}) -
Creates an EasyStreamBuilder which is a wrapper around StreamBuilder
that makes it easy to display the various states of streaming data.
const
Properties
- dataBuilder → Widget Function(BuildContext context, T data)
-
The widget which displays the snapshot's data when it's loaded.
final
- errorIcon → IconData
-
The icon which is shown when the snapshot has an error.
final
- errorText → String
-
The text which is shown when the snapshot has an error.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- iconStyle → IconThemeData?
-
IconThemeData used for the isEmptyIcon.
final
- isEmptyIcon → IconData
-
The icon which is shown when the snapshots data is empty.
(Only works on Iterable/Map.)
final
- isEmptyText → String
-
The text which is shown when the snapshots data is empty.
(Only works on Iterable/Map.)
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- loadingIndicator → Widget
-
The widget which is shown while fetching the snapshots data.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
stream
→ Stream<
T> -
The asynchronous computation to which this builder is currently connected.
final
- textStyle → TextStyle?
-
TextStyle used for the isEmptyText, errorText and error message.
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}) → 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