refactor: call fromJson constructor of base class
This commit is contained in:
parent
a5af392fb8
commit
19500307be
|
|
@ -28,10 +28,8 @@ class BasicEventWithSender extends BasicEvent {
|
|||
|
||||
BasicEventWithSender();
|
||||
|
||||
BasicEventWithSender.fromJson(Map<String, dynamic> json) {
|
||||
final basicEvent = BasicEvent.fromJson(json);
|
||||
type = basicEvent.type;
|
||||
content = basicEvent.content;
|
||||
BasicEventWithSender.fromJson(Map<String, dynamic> json)
|
||||
: super.fromJson(json) {
|
||||
senderId = json['sender'];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,10 +35,7 @@ class BasicRoomEvent extends BasicEvent {
|
|||
type: type,
|
||||
);
|
||||
|
||||
BasicRoomEvent.fromJson(Map<String, dynamic> json) {
|
||||
final basicEvent = BasicEvent.fromJson(json);
|
||||
content = basicEvent.content;
|
||||
type = basicEvent.type;
|
||||
BasicRoomEvent.fromJson(Map<String, dynamic> json) : super.fromJson(json) {
|
||||
roomId = json['room_id'];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -190,14 +190,7 @@ class StateFilter extends EventFilter {
|
|||
notSenders: notSenders,
|
||||
);
|
||||
|
||||
StateFilter.fromJson(Map<String, dynamic> json) {
|
||||
final eventFilter = EventFilter.fromJson(json);
|
||||
limit = eventFilter.limit;
|
||||
senders = eventFilter.senders;
|
||||
types = eventFilter.types;
|
||||
notRooms = eventFilter.notRooms;
|
||||
notSenders = eventFilter.notSenders;
|
||||
|
||||
StateFilter.fromJson(Map<String, dynamic> json) : super.fromJson(json) {
|
||||
notTypes = json['not_types']?.cast<String>();
|
||||
lazyLoadMembers = json['lazy_load_members'];
|
||||
includeRedundantMembers = json['include_redundant_members'];
|
||||
|
|
|
|||
|
|
@ -34,12 +34,7 @@ class MatrixEvent extends StrippedStateEvent {
|
|||
|
||||
MatrixEvent();
|
||||
|
||||
MatrixEvent.fromJson(Map<String, dynamic> json) {
|
||||
final strippedStateEvent = StrippedStateEvent.fromJson(json);
|
||||
content = strippedStateEvent.content;
|
||||
type = strippedStateEvent.type;
|
||||
senderId = strippedStateEvent.senderId;
|
||||
stateKey = strippedStateEvent.stateKey;
|
||||
MatrixEvent.fromJson(Map<String, dynamic> json) : super.fromJson(json) {
|
||||
eventId = json['event_id'];
|
||||
roomId = json['room_id'];
|
||||
originServerTs =
|
||||
|
|
|
|||
|
|
@ -27,11 +27,7 @@ import 'presence_content.dart';
|
|||
class Presence extends BasicEventWithSender {
|
||||
PresenceContent presence;
|
||||
|
||||
Presence.fromJson(Map<String, dynamic> json) {
|
||||
final basicEvent = BasicEventWithSender.fromJson(json);
|
||||
type = basicEvent.type;
|
||||
content = basicEvent.content;
|
||||
senderId = basicEvent.senderId;
|
||||
Presence.fromJson(Map<String, dynamic> json) : super.fromJson(json) {
|
||||
presence = PresenceContent.fromJson(content);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,11 +27,8 @@ class StrippedStateEvent extends BasicEventWithSender {
|
|||
String stateKey;
|
||||
|
||||
StrippedStateEvent();
|
||||
StrippedStateEvent.fromJson(Map<String, dynamic> json) {
|
||||
final basicEvent = BasicEventWithSender.fromJson(json);
|
||||
content = basicEvent.content;
|
||||
type = basicEvent.type;
|
||||
senderId = basicEvent.senderId;
|
||||
StrippedStateEvent.fromJson(Map<String, dynamic> json)
|
||||
: super.fromJson(json) {
|
||||
stateKey = json['state_key'];
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue