import 'package:chat/models/page_model.dart'; import 'package:chat/models/user_info_model.dart'; class MomentModel { MomentModel({ this.data, this.page, }); List? data; PageModel? page; factory MomentModel.fromMap(Map json) => MomentModel( data: List.from( json['data'].map( (x) => MomentItemModel.fromMap(x), ), ), page: PageModel.fromJson(json['page']), ); } class MomentItemModel { MomentItemModel({ this.dynamicId, this.user, this.description, this.pictures, this.isLike, this.isMe, this.likerCount, this.liker, this.comments, this.createdAt, this.time, }); int? dynamicId; UserInfoModel? user; String? description; bool? isLike; bool? isMe; int? likerCount; List? pictures; List? liker; List? comments; String? createdAt; String? time; factory MomentItemModel.fromMap(Map json) => MomentItemModel( dynamicId: json['dynamic_id'], user: UserInfoModel.fromJson(json['user']), description: json['description'], pictures: List.from(json['pictures'].map((x) => x)), isLike: json['is_like'], isMe: json['is_me'], likerCount: json['liker_count'], liker: List.from( json['liker'].map((x) => UserInfoModel.fromJson(x))), comments: List.from(json['comments'].map((x) => Comment.fromMap(x))), createdAt: json['created_at'], time: json['time'], ); } class Comment { Comment({ this.id, this.user, this.parent, this.content, required this.isMe, }); int? id; UserInfoModel? user; UserInfoModel? parent; String? content; bool isMe; factory Comment.fromMap(Map json) => Comment( id: json['comment_id'], parent: json['parent'] == null ? null : UserInfoModel.fromJson(json['parent']), user: UserInfoModel.fromJson(json['user']), content: json['content'], isMe: json['is_me'], ); }