From 150529a74069f115964a54358e2398d85b0358db Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Sat, 9 May 2020 09:59:05 +0200 Subject: [PATCH] Identify conversation windows with keys --- .../conversations_area_widget.dart | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/ui/widgets/tablet_mode/conversations/conversations_area_widget.dart b/lib/ui/widgets/tablet_mode/conversations/conversations_area_widget.dart index 422d63e..5e35ecb 100644 --- a/lib/ui/widgets/tablet_mode/conversations/conversations_area_widget.dart +++ b/lib/ui/widgets/tablet_mode/conversations/conversations_area_widget.dart @@ -16,13 +16,13 @@ class ConversationsAreaWidget extends StatefulWidget { } class ConversationsAreaWidgetState extends State { - final _openConversations = Set(); + final _openConversations = Map(); @override Widget build(BuildContext context) { return Row( crossAxisAlignment: CrossAxisAlignment.end, - children: _openConversations.map(_conversationWindow).toList() + children: _openConversations.map(_conversationWindow).values.toList() ..add(_buildOpenButton()), ); } @@ -32,11 +32,17 @@ class ConversationsAreaWidgetState extends State { /// Open a new conversation void openConversations(int convID) { - setState(() => _openConversations.add(convID)); + if (!_openConversations.containsKey(convID)) + setState(() => _openConversations[convID] = UniqueKey()); } - Widget _conversationWindow(int convID) => ConversationWindow( - convID: convID, - onClose: () => setState(() => _openConversations.remove(convID)), + MapEntry _conversationWindow(int convID, UniqueKey key) => + MapEntry( + convID, + ConversationWindow( + key: key, + convID: convID, + onClose: () => setState(() => _openConversations.remove(convID)), + ), ); }