create method
Future<ChatResult<ChatUser> >
create({
- List<
String> ? externalIds, - Map<
String, String> ? passwords, - String? displayName,
- String? avatarUrl,
- String? bio,
- String? email,
- 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);
}