create method

  1. @override
Future<ChatResult<ChatUser>> create({
  1. List<String>? externalIds,
  2. Map<String, String>? passwords,
  3. String? displayName,
  4. String? avatarUrl,
  5. String? bio,
  6. String? email,
  7. Map<String, dynamic>? custom,
})
override

Creates a new user, optionally linked to external IDs and seeded with profile fields (1-step creation).

Use during onboarding to register the authenticated principal against the chat backend. The auth-derived id is always used; the optional profile fields become the initial values for the new record (backend ignores them if it doesn't support inline profile creation — falls back to bare create). Subsequent calls for the same auth principal return the existing user instead of erroring, so this is safe to call on every cold start.

Implementation

@override
Future<ChatResult<ChatUser>> create({
  List<String>? externalIds,
  Map<String, String>? passwords,
  String? displayName,
  String? avatarUrl,
  String? bio,
  String? email,
  Map<String, dynamic>? custom,
}) async {
  final id = 'mock-user-${_client._users.length}';
  final user = ChatUser(
    id: id,
    displayName: displayName,
    avatarUrl: avatarUrl,
    bio: bio,
    email: email,
    custom: custom,
    active: true,
  );
  _client._users[id] = user;
  return ChatSuccess(user);
}