Merge branch 'fix-classes-non-nullable' into 'master'

[Classes] Non nullable id and mxcurl

See merge request famedly/famedlysdk!39
This commit is contained in:
Marcel 2019-07-19 17:22:59 +00:00
commit 0316795a49
3 changed files with 10 additions and 3 deletions

View file

@ -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.

View file

@ -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;

View file

@ -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/");
});
});
}