ChatRoom.fromMap constructor
Implementation
factory ChatRoom.fromMap(Map<String, dynamic> map) {
return ChatRoom(
id: map['id'] as String,
name: map['name'] as String,
type: ChatType.values.firstWhereOrNull(
(type) => type.toString().split('.').last == map['value'],
),
members: map['members'] == null
? []
: List<String>.from(
map['members'] as List<String>,
),
createdAt: map['createdAt'] == null
? null
: DateTime.fromMillisecondsSinceEpoch(map['createdAt'] as int),
updatedAt: map['updatedAt'] == null
? null
: DateTime.fromMillisecondsSinceEpoch(map['updatedAt'] as int),
messages: map['messages'] == null
? []
: List<Message>.from(
(map['messages'] as List).map<Message>(
(x) => Message.fromMap(x as Map<String, dynamic>),
),
),
);
}