ComputedAsyncNotifier<T> constructor
ComputedAsyncNotifier<T> (
- Future<
T> compute(), { - required List<
ChangeNotifier> depends, - void onError(
- dynamic error
- T? beforeUpdate()?,
Implementation
ComputedAsyncNotifier(this.compute,
{required this.depends, this.onError, this.beforeUpdate}) {
_onChange = oneCallTask(() {
_loading = true;
if (beforeUpdate != null) {
_value = beforeUpdate!();
}
_updateValue()
.then((_) => notifyListeners())
.catchError((error) => onError?.call(_error = error))
.whenComplete(() => _loading = false);
});
}