refactor: call fromJson constructor of base class

This commit is contained in:
Lukas Lihotzki 2021-05-05 12:05:26 +02:00
parent a5af392fb8
commit 19500307be
6 changed files with 8 additions and 32 deletions

View File

@ -28,10 +28,8 @@ class BasicEventWithSender extends BasicEvent {
BasicEventWithSender(); BasicEventWithSender();
BasicEventWithSender.fromJson(Map<String, dynamic> json) { BasicEventWithSender.fromJson(Map<String, dynamic> json)
final basicEvent = BasicEvent.fromJson(json); : super.fromJson(json) {
type = basicEvent.type;
content = basicEvent.content;
senderId = json['sender']; senderId = json['sender'];
} }

View File

@ -35,10 +35,7 @@ class BasicRoomEvent extends BasicEvent {
type: type, type: type,
); );
BasicRoomEvent.fromJson(Map<String, dynamic> json) { BasicRoomEvent.fromJson(Map<String, dynamic> json) : super.fromJson(json) {
final basicEvent = BasicEvent.fromJson(json);
content = basicEvent.content;
type = basicEvent.type;
roomId = json['room_id']; roomId = json['room_id'];
} }

View File

@ -190,14 +190,7 @@ class StateFilter extends EventFilter {
notSenders: notSenders, notSenders: notSenders,
); );
StateFilter.fromJson(Map<String, dynamic> json) { StateFilter.fromJson(Map<String, dynamic> json) : super.fromJson(json) {
final eventFilter = EventFilter.fromJson(json);
limit = eventFilter.limit;
senders = eventFilter.senders;
types = eventFilter.types;
notRooms = eventFilter.notRooms;
notSenders = eventFilter.notSenders;
notTypes = json['not_types']?.cast<String>(); notTypes = json['not_types']?.cast<String>();
lazyLoadMembers = json['lazy_load_members']; lazyLoadMembers = json['lazy_load_members'];
includeRedundantMembers = json['include_redundant_members']; includeRedundantMembers = json['include_redundant_members'];

View File

@ -34,12 +34,7 @@ class MatrixEvent extends StrippedStateEvent {
MatrixEvent(); MatrixEvent();
MatrixEvent.fromJson(Map<String, dynamic> json) { MatrixEvent.fromJson(Map<String, dynamic> json) : super.fromJson(json) {
final strippedStateEvent = StrippedStateEvent.fromJson(json);
content = strippedStateEvent.content;
type = strippedStateEvent.type;
senderId = strippedStateEvent.senderId;
stateKey = strippedStateEvent.stateKey;
eventId = json['event_id']; eventId = json['event_id'];
roomId = json['room_id']; roomId = json['room_id'];
originServerTs = originServerTs =

View File

@ -27,11 +27,7 @@ import 'presence_content.dart';
class Presence extends BasicEventWithSender { class Presence extends BasicEventWithSender {
PresenceContent presence; PresenceContent presence;
Presence.fromJson(Map<String, dynamic> json) { Presence.fromJson(Map<String, dynamic> json) : super.fromJson(json) {
final basicEvent = BasicEventWithSender.fromJson(json);
type = basicEvent.type;
content = basicEvent.content;
senderId = basicEvent.senderId;
presence = PresenceContent.fromJson(content); presence = PresenceContent.fromJson(content);
} }
} }

View File

@ -27,11 +27,8 @@ class StrippedStateEvent extends BasicEventWithSender {
String stateKey; String stateKey;
StrippedStateEvent(); StrippedStateEvent();
StrippedStateEvent.fromJson(Map<String, dynamic> json) { StrippedStateEvent.fromJson(Map<String, dynamic> json)
final basicEvent = BasicEventWithSender.fromJson(json); : super.fromJson(json) {
content = basicEvent.content;
type = basicEvent.type;
senderId = basicEvent.senderId;
stateKey = json['state_key']; stateKey = json['state_key'];
} }