make event model const
This commit is contained in:
@@ -10,7 +10,7 @@ part 'event.g.dart';
|
||||
@JsonSerializable()
|
||||
class Event {
|
||||
/// Constructor used for json serialization
|
||||
Event({
|
||||
const Event({
|
||||
this.type,
|
||||
this.cid,
|
||||
this.connectionId,
|
||||
@@ -27,16 +27,18 @@ class Event {
|
||||
this.channelId,
|
||||
this.channelType,
|
||||
this.parentId,
|
||||
this.extraData,
|
||||
}) : isLocal = true;
|
||||
this.extraData = const {},
|
||||
this.isLocal = true,
|
||||
});
|
||||
|
||||
/// Create a new instance from a json
|
||||
factory Event.fromJson(Map<String, dynamic> json) =>
|
||||
_$EventFromJson(Serialization.moveToExtraDataFromRoot(
|
||||
json,
|
||||
topLevelFields,
|
||||
))
|
||||
..isLocal = false;
|
||||
factory Event.fromJson(Map<String, dynamic> json) => _$EventFromJson({
|
||||
...Serialization.moveToExtraDataFromRoot(
|
||||
json,
|
||||
topLevelFields,
|
||||
),
|
||||
'is_local': false,
|
||||
});
|
||||
|
||||
/// The type of the event
|
||||
/// [EventType] contains some predefined constant types
|
||||
@@ -89,11 +91,11 @@ class Event {
|
||||
|
||||
/// True if the event is generated by this client
|
||||
@JsonKey(ignore: true)
|
||||
bool isLocal;
|
||||
final bool isLocal;
|
||||
|
||||
/// Map of custom channel extraData
|
||||
@JsonKey(includeIfNull: false)
|
||||
final Map<String, dynamic>? extraData;
|
||||
@JsonKey(defaultValue: {})
|
||||
final Map<String, dynamic> extraData;
|
||||
|
||||
/// Known top level fields.
|
||||
/// Useful for [Serialization] methods.
|
||||
@@ -114,7 +116,6 @@ class Event {
|
||||
'channel_id',
|
||||
'channel_type',
|
||||
'parent_id',
|
||||
'is_local',
|
||||
];
|
||||
|
||||
/// Serialize to json
|
||||
|
||||
Reference in New Issue
Block a user