From 3e1aee6fcd6ec24d7953f00969500861d6e5b9b8 Mon Sep 17 00:00:00 2001 From: Krille Fear Date: Fri, 5 Nov 2021 12:21:48 +0100 Subject: [PATCH] fix: Null error in get own profile On converting a User object to a Profile object now leads to an error. This fixes it. --- CHANGELOG.md | 3 +++ lib/src/client.dart | 8 ++++++-- pubspec.yaml | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b1352e20..bc36e8a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## [0.7.0-nullsafety.3] - 05nd Nov 2021 +- fix: Null error in get own profile + ## [0.7.0-nullsafety.2] - 04nd Nov 2021 - refactor: Make room in Event class not nullable - refactor: download method should not return null diff --git a/lib/src/client.dart b/lib/src/client.dart index 1b680df3..2ac2b831 100644 --- a/lib/src/client.dart +++ b/lib/src/client.dart @@ -609,9 +609,13 @@ class Client extends MatrixApi { final profileSet = {}; for (final room in rooms) { final user = room.getUserByMXIDSync(userID!); - profileSet.add(Profile.fromJson(user.content)); + profileSet.add(Profile( + avatarUrl: user.avatarUrl, + displayName: user.displayName, + userId: user.id, + )); } - if (profileSet.length == 1) return profileSet.first; + if (profileSet.length == 1) return profileSet.single; } return getProfileFromUserId(userID!); } diff --git a/pubspec.yaml b/pubspec.yaml index c661f8a7..7414c01a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: matrix description: Matrix Dart SDK -version: 0.7.0-nullsafety.2 +version: 0.7.0-nullsafety.3 homepage: https://famedly.com environment: