diff --git a/lib/src/utils/marked_unread.dart b/lib/src/utils/marked_unread.dart
index c235bbb3..0ab98099 100644
--- a/lib/src/utils/marked_unread.dart
+++ b/lib/src/utils/marked_unread.dart
@@ -1,4 +1,3 @@
-// @dart=2.9
 /*
  *   Famedly Matrix SDK
  *   Copyright (C) 2019, 2020, 2021 Famedly GmbH
@@ -17,28 +16,19 @@
  *   along with this program.  If not, see .
  */
 
+import 'package:matrix_api_lite/src/utils/try_get_map_extension.dart';
+
 mixin EventType {
   static const String markedUnread = 'com.famedly.marked_unread';
 }
 
 class MarkedUnread {
-  bool unread;
+  final bool unread;
 
-  MarkedUnread(this.unread);
+  const MarkedUnread(this.unread);
 
-  MarkedUnread.fromJson(Map json) {
-    if (!(json['unread'] is bool)) {
-      unread = false;
-    } else {
-      unread = json['unread'];
-    }
-  }
+  MarkedUnread.fromJson(Map json)
+      : unread = json.tryGet('unread') ?? false;
 
-  Map toJson() {
-    final data = {};
-    if (unread != null) {
-      data['unread'] = unread;
-    }
-    return data;
-  }
+  Map toJson() => {'unread': unread};
 }