PrismViewStateNotifier<T>.fromFuture constructor
- Future<
T> future
Creates a notifier starting in the loading state and tracking future.
Implementation
PrismViewStateNotifier.fromFuture(Future<T> future)
: super(const PrismViewLoading()) {
future.then(
(data) {
final isEmpty = data is Iterable && data.isEmpty;
value = isEmpty ? const PrismViewEmpty() : PrismViewSuccess(data);
},
onError: (Object error, StackTrace stackTrace) {
value = PrismViewError(error, stackTrace);
},
);
}