import 'package:json_annotation/json_annotation.dart'; part 'moment.g.dart'; @JsonSerializable() class Comment { int id; String username; String avatar; String content; String date; Comment({ required this.id, required this.username, required this.avatar, required this.content, required this.date, }); factory Comment.fromJson(Map json) => _$CommentFromJson(json); Map toJson() => _$CommentToJson(this); } @JsonSerializable() class Moment { int? id; int? userId; String? username; String? avatar; String content; List imageList; String? date; List? likeList; List? commentList; Moment({ this.id, this.userId, this.username, this.avatar, required this.content, required this.imageList, this.date, this.likeList, this.commentList, }); factory Moment.fromJson(Map json) => _$MomentFromJson(json); Map toJson() => _$MomentToJson(this); static Moment getEmpty() { return Moment( id: 0, content: '', imageList: [] ); } } @JsonSerializable() class PageMoment { final List records; final int total; final int size; final int current; final int pages; PageMoment({ required this.records, required this.total, required this.size, required this.current, required this.pages, }); factory PageMoment.fromJson(Map json) => _$PageMomentFromJson(json); Map toJson() => _$PageMomentToJson(this); }