Group.fromMap constructor

Group.fromMap(
  1. dynamic map
)

Creates a new Group instance from a map.

Implementation

factory Group.fromMap(dynamic map) {
  if (map == null) {
    throw ArgumentError('The type of group map is null');
  }
  return Group(
      guid: map['guid'],
      owner: map['owner'],
      name: map['name'],
      icon: map['icon'] ?? '',
      description: map['description'] ?? '',
      metadata:
          Map<String, dynamic>.from(json.decode(map['metadata'] ?? '{}')),
      hasJoined: map['hasJoined'],
      membersCount: map['membersCount'],
      createdAt: map['createdAt'] == 0 || map['createdAt'] == null
          ? null
          : DateTime.fromMillisecondsSinceEpoch(map['createdAt'] * 1000),
      joinedAt: map['joinedAt'] == 0 || map['joinedAt'] == null
          ? null
          : DateTime.fromMillisecondsSinceEpoch(map['joinedAt'] * 1000),
      updatedAt: map['updatedAt'] == 0 || map['updatedAt'] == null
          ? null
          : DateTime.fromMillisecondsSinceEpoch(map['updatedAt'] * 1000),
      tags: List<String>.from(map['tags'] ?? []),
      type: map['type'],
      scope: map['scope'],
      password: map['password'],
      isBannedFromGroup: map['isBannedFromGroup']);
}