signOut method
Implementation
Future<AuthResponse<T>> signOut({
Object? args,
String? id,
bool notifiable = true,
}) async {
emit(
AuthResponse.loading(AuthType.logout),
args: args,
id: id,
notifiable: notifiable,
);
final opToken = _beginOp();
try {
final response = await delegate.signOut();
if (!_isOpAlive(opToken)) {
return AuthResponse.failure('Cancelled', type: AuthType.logout);
}
if (!response.isSuccessful) {
return _failure(
response.error,
type: AuthType.logout,
args: args,
id: id,
notifiable: notifiable,
);
}
final prev = _backupEmitEnabled;
_backupEmitEnabled = false;
bool cleared;
try {
cleared = await _clearLocal();
} finally {
_backupEmitEnabled = prev;
}
if (!_isOpAlive(opToken)) {
return AuthResponse.failure('Cancelled', type: AuthType.logout);
}
final response2 = AuthResponse<T>.unauthenticated(
msg: cleared ? msg.signOut.done : (msg.signOut.done ?? 'Signed out'),
type: AuthType.logout,
);
return emit(response2, args: args, id: id, notifiable: notifiable);
} catch (error) {
return _failure(
msg.signOut.failure ?? error.toString(),
type: AuthType.logout,
args: args,
id: id,
notifiable: notifiable,
);
}
}