ReactiveNullableList<T> class
A reactive widget that renders a UI based on a nullable list.
This widget listens to a reactiveKey and rebuilds when notified via refresh or refreshOnly. It handles three scenarios:
- If values is
null, it renders ifNull. - If values is empty, it renders ifEmpty.
- If values is non-empty, it renders builder with the list.
Useful for conditionally rendering lists with loading and empty states.
Example:
List<String>? users;
ReactiveNullableList<String>(
values: users,
builder: (list) => ListView(children: list.map(Text.new).toList()),
ifNull: CircularProgressIndicator(),
ifEmpty: Text("No users found"),
)
// Later...
users = ["Alice", "Bob"];
refresh();
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- ReactiveNullableList
Constructors
-
ReactiveNullableList({Key? key, List<
T> ? values, Widget ifNull = const Nothing(), Widget ifEmpty = const Nothing(), required Widget builder(List<T> ), Key? reactiveKey}) -
Creates a ReactiveNullableList that rebuilds reactively
and displays different widgets depending on the state of
values.
Properties
-
builder
→ Widget Function(List<
T> ) -
Builder called when values is non-null and not empty.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- ifEmpty → Widget
-
Widget to display if values is an empty list.
final
- ifNull → Widget
-
Widget to display if values is null.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- reactiveKey → Key
-
Key used to identify which reactive updates this widget listens to.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
values
→ List<
T> ? -
The list of values to evaluate and pass to builder.
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< ReactiveNullableList< T> > -
Creates the mutable state for this widget at a given location in the tree.
override
-
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