setUser method

Future<QAccount> setUser({
  1. required String userId,
  2. required String userKey,
  3. String? username,
  4. String? avatarUrl,
  5. Json? extras,
})

Implementation

Future<QAccount> setUser({
  required String userId,
  required String userKey,
  String? username,
  String? avatarUrl,
  Json? extras,
}) async {
  if (userId.isEmpty) {
    throw ArgumentError.value(
      userId,
      'userId',
      'userId should not be empty string',
    );
  }
  if (userKey.isEmpty) {
    throw ArgumentError.value(
      userKey,
      'userKey',
      'userKey should not be empty string',
    );
  }

  return setUserImpl(
    userId: userId,
    userKey: userKey,
    displayName: username,
    avatarUrl: avatarUrl,
    extras: extras,
  )
      .run(_dio)
      .map((state) {
        var data = state.run(_storage);

        _storage = data.second;
        return data.first;
      })
      .runOrThrow()
      .tap((_) => _connectMqtt());
}