[Event] Add trycatch block
This commit is contained in:
parent
6117606b28
commit
5df56ea12f
|
@ -66,8 +66,12 @@ class RawEvent {
|
|||
this.room});
|
||||
|
||||
static Map<String, dynamic> getMapFromPayload(dynamic payload) {
|
||||
if (payload == null || payload == "") return {};
|
||||
if (payload is String) return json.decode(payload);
|
||||
if (payload is String)
|
||||
try {
|
||||
return json.decode(payload);
|
||||
} catch (e) {
|
||||
return {};
|
||||
}
|
||||
if (payload is Map<String, dynamic>) return payload;
|
||||
return {};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue