User constructor
User({})
Creates a new user.
If an name
is provided it will be set on extraData
with a key
of 'name'.
For example:
final user = User(id: 'id', name: 'Sahil Kumar');
print(user.name == user.extraData['name']); // true
If an image
is provided it will be set on extraData
with a key
of 'image'.
For example:
final user = User(id: 'id', image: 'https://getstream.io/image.png');
print(user.image == user.extraData['image']); // true
Implementation
User({
required this.id,
this.role,
String? name,
String? image,
this.createdAt,
this.updatedAt,
this.lastActive,
Map<String, Object?> extraData = const {},
this.online = false,
this.banned = false,
this.banExpires,
this.teams = const [],
this.language,
}) :
// For backwards compatibility, set 'name', 'image' in [extraData].
extraData = {
...extraData,
if (name != null) 'name': name,
if (image != null) 'image': image,
};