wait<T> method
PROTECTED
A wrapper for a any Future computation which will automatically toggle
the controller-wide isLoading state, with optional tag
for a specific
state.
Returns computation
result, and rethrow any errors found.
Implementation
@override
@protected
Future<T?> wait<T>(Future<T> computation, {String? tag,}) async {
if (tag != null) {
setIsLoadingByTag(tag, true,);
try {
final result = await computation;
setIsLoadingByTag(tag, false,);
return result;
} catch (err) {
setIsLoadingByTag(tag, false,);
rethrow;
}
} else {
isLoading = true;
try {
final result = await computation;
isLoading = false;
return result;
} catch (err) {
isLoading = false;
rethrow;
}
}
}