fix: Use Uri.tryParse where applicable

This commit is contained in:
Sorunome 2020-11-19 14:59:05 +01:00
parent f84d5fed6d
commit b67ab870fa
No known key found for this signature in database
GPG Key ID: B19471D07FC9BE9C
2 changed files with 3 additions and 3 deletions

View File

@ -211,7 +211,7 @@ class Room {
Uri get avatar {
if (states[EventTypes.RoomAvatar] != null &&
states[EventTypes.RoomAvatar].content['url'] is String) {
return Uri.parse(states[EventTypes.RoomAvatar].content['url']);
return Uri.tryParse(states[EventTypes.RoomAvatar].content['url']);
}
if (mHeroes != null && mHeroes.length == 1 && states[mHeroes[0]] != null) {
return states[mHeroes[0]].asUser.avatarUrl;

View File

@ -94,10 +94,10 @@ class User extends Event {
/// The avatar if the user has one.
Uri get avatarUrl => content != null && content.containsKey('avatar_url')
? (content['avatar_url'] is String
? Uri.parse(content['avatar_url'])
? Uri.tryParse(content['avatar_url'])
: null)
: (prevContent != null && prevContent['avatar_url'] is String
? Uri.parse(prevContent['avatar_url'])
? Uri.tryParse(prevContent['avatar_url'])
: null);
/// Returns the displayname or the local part of the Matrix ID if the user