Suspense<T> class

DSL sugar for SuspenseNode.

Renders fallback while async data is loading, and seamlessly swaps in the resolved content when resource completes.

Future<String> fetchUsername() async {
  await Future.delayed(const Duration(milliseconds: 500));
  return 'Ada Lovelace';
}

BloomNode userProfile() => Suspense<String>(
  resource: fetchUsername,
  fallback: Div(className: 'skeleton-loader', text: 'Loading user...'),
  builder: (name) => Div(className: 'user-card', text: 'Welcome, $name!'),
  errorBuilder: (err, stack) => Div(text: 'Failed to load user: $err'),
);
Inheritance

Constructors

Suspense({required Future<T> resource(), required BloomNode builder(T data), required BloomNode fallback, BloomNode errorBuilder(Object error, StackTrace stackTrace)?})
Creates a suspense boundary with async resource, builder, fallback, and optional errorBuilder.
const

Properties

builder BloomNode Function(T data)
Builder constructing the descriptor tree once resource resolves with data.
finalinherited
builderErased BloomNode Function(Object? value)
builder, accepting untyped resolved Object? data.
no setterinherited
errorBuilder BloomNode Function(Object error, StackTrace stackTrace)?
Optional error builder invoked if resource rejects with an exception.
finalinherited
fallback BloomNode
Descriptor tree displayed while resource is still pending.
finalinherited
hashCode int
The hash code for this object.
no setterinherited
resource Future<T> Function()
Async factory returning a Future with the resolved data of type T.
finalinherited
resourceErased Future<Object?> Function()
resource, viewed untyped as Future<Object?> Function().
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited