login method Null safety
An app user logs in to the chat server with a password or token.
Param username
The username.
Param pwdOrToken
The password or token.
Param isPassword
Whether to log in with password or token.
true
: (default) Log in with password.
false
: Log in with token.
Throws A description of the exception. See {@link EMError}.
Implementation
Future<void> login(String username, String pwdOrToken,
[bool isPassword = true]) async {
EMLog.v('login: $username : $pwdOrToken, isPassword: $isPassword');
Map req = {
'username': username,
'pwdOrToken': pwdOrToken,
'isPassword': isPassword
};
Map result = await _channel.invokeMethod(ChatMethodKeys.login, req);
try {
EMError.hasErrorFromResult(result);
_currentUsername = username;
} on EMError catch (e) {
throw e;
}
}