refactor: Update to Dart 3.10 with . shorthands

This commit is contained in:
Christian Kußowski 2025-11-30 12:54:06 +01:00
commit 1ea649f01e
No known key found for this signature in database
GPG key ID: E067ECD60F1A0652
167 changed files with 3351 additions and 3912 deletions

View file

@ -99,13 +99,16 @@ class UrlLauncher {
// okay, we have either an http or an https URI.
// As some platforms have issues with opening unicode URLs, we are going to help
// them out by punycode-encoding them for them ourself.
final newHost = uri.host.split('.').map((hostPartEncoded) {
final hostPart = Uri.decodeComponent(hostPartEncoded);
final hostPartPunycode = punycodeEncode(hostPart);
return hostPartPunycode != '$hostPart-'
? 'xn--$hostPartPunycode'
: hostPart;
}).join('.');
final newHost = uri.host
.split('.')
.map((hostPartEncoded) {
final hostPart = Uri.decodeComponent(hostPartEncoded);
final hostPartPunycode = punycodeEncode(hostPart);
return hostPartPunycode != '$hostPart-'
? 'xn--$hostPartPunycode'
: hostPart;
})
.join('.');
// Force LaunchMode.externalApplication, otherwise url_launcher will default
// to opening links in a webview on mobile platforms.
launchUrlString(
@ -117,17 +120,17 @@ class UrlLauncher {
void openMatrixToUrl() async {
final matrix = Matrix.of(context);
final url = this.url!.replaceFirst(
AppConfig.deepLinkPrefix,
AppConfig.inviteLinkPrefix,
);
AppConfig.deepLinkPrefix,
AppConfig.inviteLinkPrefix,
);
// The identifier might be a matrix.to url and needs escaping. Or, it might have multiple
// identifiers (room id & event id), or it might also have a query part.
// All this needs parsing.
final identityParts = url.parseIdentifierIntoParts() ??
final identityParts =
url.parseIdentifierIntoParts() ??
Uri.tryParse(url)?.host.parseIdentifierIntoParts() ??
Uri.tryParse(url)
?.pathSegments
Uri.tryParse(url)?.pathSegments
.lastWhereOrNull((_) => true)
?.parseIdentifierIntoParts();
if (identityParts == null) {
@ -138,7 +141,8 @@ class UrlLauncher {
// we got a room! Let's open that one
final roomIdOrAlias = identityParts.primaryIdentifier;
final event = identityParts.secondaryIdentifier;
var room = matrix.client.getRoomByAlias(roomIdOrAlias) ??
var room =
matrix.client.getRoomByAlias(roomIdOrAlias) ??
matrix.client.getRoomById(roomIdOrAlias);
var roomId = room?.id;
// we make the servers a set and later on convert to a list, so that we can easily
@ -168,10 +172,7 @@ class UrlLauncher {
// we have the room, so....just open it
if (event != null) {
context.go(
'/${Uri(
pathSegments: ['rooms', room.id],
queryParameters: {'event': event},
)}',
'/${Uri(pathSegments: ['rooms', room.id], queryParameters: {'event': event})}',
);
} else {
context.go('/rooms/${room.id}');
@ -180,9 +181,8 @@ class UrlLauncher {
} else {
await showAdaptiveDialog(
context: context,
builder: (c) => PublicRoomDialog(
roomAlias: identityParts.primaryIdentifier,
),
builder: (c) =>
PublicRoomDialog(roomAlias: identityParts.primaryIdentifier),
);
}
if (roomIdOrAlias.sigil == '!') {
@ -223,12 +223,11 @@ class UrlLauncher {
var noProfileWarning = false;
final profileResult = await showFutureLoadingDialog(
context: context,
future: () => matrix.client.getProfileFromUserId(userId).catchError(
(_) {
noProfileWarning = true;
return Profile(userId: userId);
},
),
future: () =>
matrix.client.getProfileFromUserId(userId).catchError((_) {
noProfileWarning = true;
return Profile(userId: userId);
}),
);
await UserDialog.show(
context: context,