Community.fromJson constructor
Community.fromJson(
- dynamic json
Implementation
factory Community.fromJson(dynamic json) {
final map = json is Map<String, dynamic> ? json : readMap(json);
return Community(
id: readInt(map["id"]),
name: map["name"]?.toString() ?? '',
slug: map["slug"]?.toString() ?? '',
description: map["description"]?.toString(),
bannerImage: map["banner_image"]?.toString(),
isActive: map["is_active"] == null ? null : readBool(map["is_active"]),
allowPosts:
map["allow_posts"] == null ? null : readBool(map["allow_posts"]),
moderatePosts: map["moderate_posts"] == null
? null
: readBool(map["moderate_posts"]),
app: map['app'] != null
? CommunityApp.fromJson(readMap(map["app"]))
: null,
createdAt: map['created_at'] != null
? DateTime.tryParse(map["created_at"].toString())
: null,
updatedAt: map['updated_at'] != null
? DateTime.tryParse(map["updated_at"].toString())
: null,
);
}