mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2024-12-17 17:20:21 +01:00
44 lines
1.0 KiB
Dart
44 lines
1.0 KiB
Dart
import 'dart:convert';
|
|
|
|
class Group {
|
|
final String photoPath;
|
|
final String groupName;
|
|
final String groupDescription;
|
|
final List<dynamic> members;
|
|
|
|
Group(
|
|
{this.groupName,
|
|
this.photoPath,
|
|
this.groupDescription,
|
|
this.members = const []});
|
|
|
|
factory Group.fromJson(Map<String, dynamic> json) {
|
|
return Group(
|
|
photoPath: json['gPhoto'],
|
|
groupName: json['gName'],
|
|
groupDescription: json['desc'],
|
|
members: json['contacts'],
|
|
);
|
|
}
|
|
|
|
static Map<String, dynamic> toJson(Group group) {
|
|
return {
|
|
'gPhoto': group.photoPath,
|
|
'gName': group.groupName,
|
|
'desc': group.groupDescription,
|
|
'contacts': group.members,
|
|
};
|
|
}
|
|
|
|
static String encode(List<Group> groups) => json.encode(
|
|
groups
|
|
.map<Map<String, dynamic>>((group) => Group.toJson(group))
|
|
.toList(),
|
|
);
|
|
|
|
static List<Group> decode(String groups) =>
|
|
(json.decode(groups) as List<dynamic>)
|
|
.map<Group>((item) => Group.fromJson(item))
|
|
.toList();
|
|
}
|