createAccount method Null safety

Future<void> createAccount(
  1. String username,
  2. String password
)

Register a new user.

Param username The username. The maximum length is 64 characters. Ensure that you set this parameter. Supported characters include the 26 English letters (a-z), the ten numbers (0-9), the underscore (_), the hyphen (-), and the English period (.). This parameter is case insensitive, and upper-case letters are automatically changed to low-case ones. If you want to set this parameter as a regular expression, set it as ^a-zA-Z0-9_-+$.

Param password The password. The maximum length is 64 characters. Ensure that you set this parameter.

Throws A description of the exception. See {@link EMError}.

Implementation

Future<void> createAccount(String username, String password) async {
  EMLog.v('create account: $username : $password');
  Map req = {'username': username, 'password': password};
  Map result = await _channel.invokeMethod(ChatMethodKeys.createAccount, req);
  try {
    EMError.hasErrorFromResult(result);
  } on EMError catch (e) {
    throw e;
  }
}