login method Null safety

Future<void> login(
  1. String username,
  2. String pwdOrToken,
  3. [bool isPassword = true]
)

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;
  }
}