feat:增加朋友圈组件
This commit is contained in:
53
lib/models/moment.dart
Normal file
53
lib/models/moment.dart
Normal file
@@ -0,0 +1,53 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'moment.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class Comment {
|
||||
final int id;
|
||||
final String username;
|
||||
final String avatar;
|
||||
final String content;
|
||||
final String date;
|
||||
|
||||
const Comment({
|
||||
required this.id,
|
||||
required this.username,
|
||||
required this.avatar,
|
||||
required this.content,
|
||||
required this.date,
|
||||
});
|
||||
|
||||
factory Comment.fromJson(Map<String, dynamic> json) => _$CommentFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$CommentToJson(this);
|
||||
}
|
||||
|
||||
@JsonSerializable()
|
||||
class Moment {
|
||||
final int? id;
|
||||
final int? userId;
|
||||
final String? username;
|
||||
final String? avatar;
|
||||
final String content;
|
||||
final List<String> imageList;
|
||||
final String? date;
|
||||
final List<int>? likeList;
|
||||
final List<Comment>? 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<String, dynamic> json) => _$MomentFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$MomentToJson(this);
|
||||
}
|
||||
54
lib/models/moment.g.dart
Normal file
54
lib/models/moment.g.dart
Normal file
@@ -0,0 +1,54 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'moment.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
Comment _$CommentFromJson(Map<String, dynamic> json) => Comment(
|
||||
id: (json['id'] as num).toInt(),
|
||||
username: json['username'] as String,
|
||||
avatar: json['avatar'] as String,
|
||||
content: json['content'] as String,
|
||||
date: json['date'] as String,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$CommentToJson(Comment instance) => <String, dynamic>{
|
||||
'id': instance.id,
|
||||
'username': instance.username,
|
||||
'avatar': instance.avatar,
|
||||
'content': instance.content,
|
||||
'date': instance.date,
|
||||
};
|
||||
|
||||
Moment _$MomentFromJson(Map<String, dynamic> json) => Moment(
|
||||
id: (json['id'] as num?)?.toInt(),
|
||||
userId: (json['userId'] as num?)?.toInt(),
|
||||
username: json['username'] as String?,
|
||||
avatar: json['avatar'] as String?,
|
||||
content: json['content'] as String,
|
||||
imageList:
|
||||
(json['imageList'] as List<dynamic>).map((e) => e as String).toList(),
|
||||
date: json['date'] as String?,
|
||||
likeList:
|
||||
(json['likeList'] as List<dynamic>?)
|
||||
?.map((e) => (e as num).toInt())
|
||||
.toList(),
|
||||
commentList:
|
||||
(json['commentList'] as List<dynamic>?)
|
||||
?.map((e) => Comment.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$MomentToJson(Moment instance) => <String, dynamic>{
|
||||
'id': instance.id,
|
||||
'userId': instance.userId,
|
||||
'username': instance.username,
|
||||
'avatar': instance.avatar,
|
||||
'content': instance.content,
|
||||
'imageList': instance.imageList,
|
||||
'date': instance.date,
|
||||
'likeList': instance.likeList,
|
||||
'commentList': instance.commentList,
|
||||
};
|
||||
Reference in New Issue
Block a user