From 906f8c31612a504f9b0922f235dbe408cbbb3ffd Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Sat, 11 Mar 2023 14:38:47 +0100 Subject: [PATCH] fix: type error in emote pack list in rooms with only non-default packs If a room has emote packs, but none of them have an empty state key, we insert 'null' to also add a default pack people can easily edit. However, in that case we initialized the Map variable with a Map. As such assigning null will throw. Converting manually with Map.of fixes that. fixes #1138 --- .../settings_multiple_emotes_view.dart | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/pages/settings_multiple_emotes/settings_multiple_emotes_view.dart b/lib/pages/settings_multiple_emotes/settings_multiple_emotes_view.dart index 6a61b8df..bfb1431e 100644 --- a/lib/pages/settings_multiple_emotes/settings_multiple_emotes_view.dart +++ b/lib/pages/settings_multiple_emotes/settings_multiple_emotes_view.dart @@ -24,8 +24,11 @@ class MultipleEmotesSettingsView extends StatelessWidget { body: StreamBuilder( stream: room.onUpdate.stream, builder: (context, snapshot) { - final Map packs = - room.states['im.ponies.room_emotes'] ?? {}; + final packStateEvents = room.states['im.ponies.room_emotes']; + // we need to manually convert the map using Map.of, otherwise assigning null will throw a type error. + final Map packs = packStateEvents != null + ? Map.of(packStateEvents) + : {}; if (!packs.containsKey('')) { packs[''] = null; }