runAuthAction method
void
runAuthAction(
- Future<void> action(), {
- AuthState endState = AuthState.signedIn,
})
Implementation
void runAuthAction(Future<void> Function() action,
{AuthState endState = AuthState.signedIn}) async {
runInAction(() => authState.value = AuthState.inProgress);
try {
_cancelOtherOperations();
_resetOtherFlows();
final operation =
CancelableOperation<void>.fromFuture(action(), onCancel: () {
runInAction(() => authState.value = AuthState.cancelled);
});
_operations.add(operation);
await operation.valueOrCancellation();
if (operation.isCompleted) {
runInAction(() => authState.value = endState);
}
} catch (e) {
error = e;
runInAction(() => authState.value = AuthState.error);
}
}