ResourceBuilder API docs
Reacts to the resource calling the builder each time.
final counter = Resource(
fetcher: () => Future.value(1),
);
@override
Widget build(BuildContext context) {
return ResourceBuilder(
resource: counter,
builder: (context, counterState) {
return switch (counterState) {
ResourceReady(:final value) => Text(value),
ResourceError(:final error, :final stackTrace) =>
Text('$error, $stackTrace'),
ResourceLoading() => const CircularProgressIndicator(),
}
},
);
}