From 8a09a2b837a1c08f371d23243a284a9c1d9beb0a Mon Sep 17 00:00:00 2001 From: Wilko Manger Date: Mon, 28 Oct 2019 15:09:07 +0100 Subject: [PATCH] [RoomList] Add copyWith method --- lib/src/RoomList.dart | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/src/RoomList.dart b/lib/src/RoomList.dart index a3ffdeb..9882eb6 100644 --- a/lib/src/RoomList.dart +++ b/lib/src/RoomList.dart @@ -75,6 +75,24 @@ class RoomList { sort(); } + RoomList copyWith({ + Client client, + List rooms, + onRoomListUpdateCallback onUpdate, + onRoomListInsertCallback onInsert, + onRoomListRemoveCallback onRemove, + bool onlyLeft, + }) { + return RoomList( + client: client ?? this.client, + rooms: rooms ?? this.rooms, + onUpdate: onUpdate ?? this.onUpdate, + onInsert: onInsert ?? this.onInsert, + onRemove: onRemove ?? this.onRemove, + onlyLeft: onlyLeft ?? this.onlyLeft, + ); + } + Room getRoomByAlias(String alias) { for (int i = 0; i < rooms.length; i++) { if (rooms[i].canonicalAlias == alias) return rooms[i];