login method Null safety

void login(
  1. String username,
  2. String password,
  3. String appkey,
  4. String subDomain,
  5. String role
)

Implementation

static void login(String username, String password, String appkey,
    String subDomain, String role) async {
  //
  SpUtil.putString(BytedeskConstants.role, role);
  if (role == BytedeskConstants.ROLE_ADMIN) {
    if (!username.contains("@")) {
      username = username + "@" + subDomain;
    }
  }
  await BytedeskUserHttpApi().oauth(username, password);
  // 登录成功之后,建立长连接
  BytedeskUtils.mqttConnect();
  if (role == BytedeskConstants.ROLE_ADMIN) {
    // TODO: 如果是客服账号,加载个人信息
  }
  // 上传设备信息
  await BytedeskDeviceHttpApi().setDeviceInfo();
}