From 740ac0dc9c1c32a6660e25ff217ee95a6a32adbc Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Fri, 19 Jul 2019 19:09:34 +0200 Subject: [PATCH 1/2] [Classes] Non nullable id and mxcurl --- lib/src/User.dart | 4 ++-- lib/src/utils/MxContent.dart | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/src/User.dart b/lib/src/User.dart index 907bdea..a45d101 100644 --- a/lib/src/User.dart +++ b/lib/src/User.dart @@ -66,13 +66,13 @@ class User { MxContent get avatar_url => avatarUrl; User( - this.id, { + String id, { this.membership, this.displayName, this.avatarUrl, this.powerLevel, this.room, - }); + }) : this.id = id ?? ""; /// Returns the displayname or the local part of the Matrix ID if the user /// has no displayname. diff --git a/lib/src/utils/MxContent.dart b/lib/src/utils/MxContent.dart index d7a0c23..05f9bc7 100644 --- a/lib/src/utils/MxContent.dart +++ b/lib/src/utils/MxContent.dart @@ -29,7 +29,7 @@ class MxContent { final String _mxc; /// Insert a mxc:// uri here. - MxContent(this._mxc); + MxContent(String mxcUrl) : this._mxc = mxcUrl ?? ""; /// Returns the mxc uri. get mxc => _mxc; From d5326772d75e2c0b6b465888eedddce7b10314c7 Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Fri, 19 Jul 2019 19:12:15 +0200 Subject: [PATCH 2/2] [Tests] Check if crash if null --- test/MxContent_test.dart | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/MxContent_test.dart b/test/MxContent_test.dart index cfdc5ca..8f4905a 100644 --- a/test/MxContent_test.dart +++ b/test/MxContent_test.dart @@ -43,5 +43,12 @@ void main() { width: 50, height: 50, method: ThumbnailMethod.scale), "${client.homeserver}/_matrix/media/r0/thumbnail/exampleserver.abc/abcdefghijklmn?width=50&height=50&method=scale"); }); + test("Not crashing if null", () async { + Client client = Client("testclient"); + client.homeserver = "https://testserver.abc"; + final MxContent content = MxContent(null); + expect(content.getDownloadLink(client), + "${client.homeserver}/_matrix/media/r0/download/"); + }); }); }