logout method
void
logout({
- dynamic onSuccess() = _defaultOnLogout,
- dynamic onError(
- LogoutError error
- LogoutParams params = const LogoutParams._(),
Logs out the current user.
Calls onSuccess
after logout. In case any error was encountered during
logout calls onError
instead.
params
are added for backwards compatibility and for now are always empty.
Usage example:
final vkid = await VKID.getInstance();
vkid.logout(
. onSuccess: () => print("success"),
onError: (error) => print(error),
);
Implementation
void logout({
Function() onSuccess = _defaultOnLogout,
Function(LogoutError error) onError = _defaultOnLogoutError,
LogoutParams params = const LogoutParams._(),
}) async {
try {
await _platform.invokeMethod("logout", []);
onSuccess();
} on PlatformException catch (e) {
onError(e.code == "expired"
? const LogoutAccessTokenExpiredError._()
: LogoutOtherError._(e.message ?? ""));
} catch (e) {
onError(const LogoutOtherError._("unknown error"));
}
}