@@ -12,11 +12,11 @@ class Reaction {
|
||||
this.messageId,
|
||||
DateTime? createdAt,
|
||||
required this.type,
|
||||
required this.user,
|
||||
this.user,
|
||||
String? userId,
|
||||
this.score = 0,
|
||||
this.extraData,
|
||||
}) : userId = userId ?? user.id,
|
||||
}) : userId = userId ?? user?.id,
|
||||
createdAt = createdAt ?? DateTime.now();
|
||||
|
||||
/// Create a new instance from a json
|
||||
@@ -38,7 +38,7 @@ class Reaction {
|
||||
|
||||
/// The user that sent the reaction
|
||||
@JsonKey(includeIfNull: false, toJson: Serialization.readOnly)
|
||||
final User user;
|
||||
final User? user;
|
||||
|
||||
/// The score of the reaction (ie. number of reactions sent)
|
||||
@JsonKey(defaultValue: 0)
|
||||
|
||||
@@ -13,7 +13,9 @@ Reaction _$ReactionFromJson(Map<String, dynamic> json) {
|
||||
? null
|
||||
: DateTime.parse(json['created_at'] as String),
|
||||
type: json['type'] as String,
|
||||
user: User.fromJson(json['user'] as Map<String, dynamic>),
|
||||
user: json['user'] == null
|
||||
? null
|
||||
: User.fromJson(json['user'] as Map<String, dynamic>),
|
||||
userId: json['user_id'] as String?,
|
||||
score: json['score'] as int? ?? 0,
|
||||
extraData: json['extra_data'] as Map<String, dynamic>?,
|
||||
|
||||
Reference in New Issue
Block a user