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

@ -49,7 +49,8 @@ class AdaptiveDialogAction extends StatelessWidget {
child: ElevatedButton(
style: ElevatedButton.styleFrom(
shape: RoundedRectangleBorder(
borderRadius: borderRadius ??
borderRadius:
borderRadius ??
BorderRadius.circular(AppConfig.borderRadius),
),
backgroundColor: autofocus

View file

@ -86,10 +86,7 @@ class DialogTextField extends StatelessWidget {
if (errorText != null)
Text(
errorText,
style: TextStyle(
fontSize: 11,
color: theme.colorScheme.error,
),
style: TextStyle(fontSize: 11, color: theme.colorScheme.error),
textAlign: TextAlign.left,
),
],

View file

@ -37,10 +37,7 @@ class PublicRoomDialog extends StatelessWidget {
}
final roomId = chunk != null && knock
? await client.knockRoom(chunk.roomId, via: via)
: await client.joinRoom(
roomAlias ?? chunk!.roomId,
via: via,
);
: await client.joinRoom(roomAlias ?? chunk!.roomId, via: via);
if (!knock && client.getRoomById(roomId) == null) {
await client.waitForRoomInSync(roomId);
@ -78,11 +75,9 @@ class PublicRoomDialog extends StatelessWidget {
final chunk = this.chunk;
if (chunk != null) return chunk;
final query = await Matrix.of(context).client.queryPublicRooms(
server: roomAlias!.domain,
filter: PublicRoomQueryFilter(
genericSearchTerm: roomAlias,
),
);
server: roomAlias!.domain,
filter: PublicRoomQueryFilter(genericSearchTerm: roomAlias),
);
if (!query.chunk.any(_testRoom)) {
throw (L10n.of(context).noRoomsFound);
}
@ -115,8 +110,8 @@ class PublicRoomDialog extends StatelessWidget {
return SingleChildScrollView(
child: Column(
spacing: 8,
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisSize: .min,
crossAxisAlignment: .stretch,
children: [
if (roomLink != null)
HoverBuilder(
@ -125,9 +120,7 @@ class PublicRoomDialog extends StatelessWidget {
cursor: SystemMouseCursors.click,
child: GestureDetector(
onTap: () {
Clipboard.setData(
ClipboardData(text: roomLink),
);
Clipboard.setData(ClipboardData(text: roomLink));
setState(() {
copied = true;
});
@ -137,8 +130,9 @@ class PublicRoomDialog extends StatelessWidget {
children: [
WidgetSpan(
child: Padding(
padding:
const EdgeInsets.only(right: 4.0),
padding: const EdgeInsets.only(
right: 4.0,
),
child: AnimatedScale(
duration:
FluffyThemes.animationDuration,
@ -146,8 +140,8 @@ class PublicRoomDialog extends StatelessWidget {
scale: hovered
? 1.33
: copied
? 1.25
: 1.0,
? 1.25
: 1.0,
child: Icon(
copied
? Icons.check_circle
@ -160,8 +154,9 @@ class PublicRoomDialog extends StatelessWidget {
),
TextSpan(text: roomLink),
],
style: theme.textTheme.bodyMedium
?.copyWith(fontSize: 10),
style: theme.textTheme.bodyMedium?.copyWith(
fontSize: 10,
),
),
textAlign: TextAlign.center,
),
@ -176,25 +171,26 @@ class PublicRoomDialog extends StatelessWidget {
size: Avatar.defaultSize * 2,
onTap: avatar != null
? () => showDialog(
context: context,
builder: (_) => MxcImageViewer(avatar),
)
context: context,
builder: (_) => MxcImageViewer(avatar),
)
: null,
),
),
if (profile?.numJoinedMembers != null)
Text(
L10n.of(context).countParticipants(
profile?.numJoinedMembers ?? 0,
),
L10n.of(
context,
).countParticipants(profile?.numJoinedMembers ?? 0),
style: const TextStyle(fontSize: 10),
textAlign: TextAlign.center,
),
if (topic != null && topic.isNotEmpty)
SelectableLinkify(
text: topic,
textScaleFactor:
MediaQuery.textScalerOf(context).scale(1),
textScaleFactor: MediaQuery.textScalerOf(
context,
).scale(1),
textAlign: TextAlign.center,
options: const LinkifyOptions(humanize: false),
linkStyle: TextStyle(
@ -221,8 +217,8 @@ class PublicRoomDialog extends StatelessWidget {
Matrix.of(context).client.getRoomById(chunk!.roomId) == null
? L10n.of(context).knock
: chunk?.roomType == 'm.space'
? L10n.of(context).joinSpace
: L10n.of(context).joinRoom,
? L10n.of(context).joinSpace
: L10n.of(context).joinRoom,
),
),
AdaptiveDialogAction(

View file

@ -32,10 +32,7 @@ Future<T?> showModalActionPopup<T>({
ListTile(
title: title == null
? null
: Text(
title,
style: theme.textTheme.labelSmall,
),
: Text(title, style: theme.textTheme.labelSmall),
subtitle: message == null ? null : Text(message),
),
const Divider(height: 1),
@ -49,8 +46,9 @@ Future<T?> showModalActionPopup<T>({
style: action.isDestructive
? TextStyle(
color: theme.colorScheme.error,
fontWeight:
action.isDefaultAction ? FontWeight.bold : null,
fontWeight: action.isDefaultAction
? FontWeight.bold
: null,
)
: null,
),

View file

@ -16,50 +16,49 @@ Future<OkCancelResult?> showOkCancelAlertDialog({
String? cancelLabel,
bool isDestructive = false,
bool useRootNavigator = true,
}) =>
showAdaptiveDialog<OkCancelResult>(
context: context,
useRootNavigator: useRootNavigator,
builder: (context) => AlertDialog.adaptive(
title: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 256),
child: Text(title),
),
content: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 256),
child: message == null
? null
: SelectableLinkify(
text: message,
textScaleFactor: MediaQuery.textScalerOf(context).scale(1),
linkStyle: TextStyle(
color: Theme.of(context).colorScheme.primary,
decorationColor: Theme.of(context).colorScheme.primary,
),
options: const LinkifyOptions(humanize: false),
onOpen: (url) => UrlLauncher(context, url.url).launchUrl(),
),
),
actions: [
AdaptiveDialogAction(
onPressed: () => Navigator.of(context)
.pop<OkCancelResult>(OkCancelResult.cancel),
child: Text(cancelLabel ?? L10n.of(context).cancel),
),
AdaptiveDialogAction(
onPressed: () =>
Navigator.of(context).pop<OkCancelResult>(OkCancelResult.ok),
autofocus: true,
child: Text(
okLabel ?? L10n.of(context).ok,
style: isDestructive
? TextStyle(color: Theme.of(context).colorScheme.error)
: null,
}) => showAdaptiveDialog<OkCancelResult>(
context: context,
useRootNavigator: useRootNavigator,
builder: (context) => AlertDialog.adaptive(
title: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 256),
child: Text(title),
),
content: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 256),
child: message == null
? null
: SelectableLinkify(
text: message,
textScaleFactor: MediaQuery.textScalerOf(context).scale(1),
linkStyle: TextStyle(
color: Theme.of(context).colorScheme.primary,
decorationColor: Theme.of(context).colorScheme.primary,
),
options: const LinkifyOptions(humanize: false),
onOpen: (url) => UrlLauncher(context, url.url).launchUrl(),
),
),
],
),
actions: [
AdaptiveDialogAction(
onPressed: () =>
Navigator.of(context).pop<OkCancelResult>(OkCancelResult.cancel),
child: Text(cancelLabel ?? L10n.of(context).cancel),
),
);
AdaptiveDialogAction(
onPressed: () =>
Navigator.of(context).pop<OkCancelResult>(OkCancelResult.ok),
autofocus: true,
child: Text(
okLabel ?? L10n.of(context).ok,
style: isDestructive
? TextStyle(color: Theme.of(context).colorScheme.error)
: null,
),
),
],
),
);
Future<OkCancelResult?> showOkAlertDialog({
required BuildContext context,
@ -67,37 +66,36 @@ Future<OkCancelResult?> showOkAlertDialog({
String? message,
String? okLabel,
bool useRootNavigator = true,
}) =>
showAdaptiveDialog<OkCancelResult>(
context: context,
useRootNavigator: useRootNavigator,
builder: (context) => AlertDialog.adaptive(
title: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 256),
child: Text(title),
),
content: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 256),
child: message == null
? null
: SelectableLinkify(
text: message,
textScaleFactor: MediaQuery.textScalerOf(context).scale(1),
linkStyle: TextStyle(
color: Theme.of(context).colorScheme.primary,
decorationColor: Theme.of(context).colorScheme.primary,
),
options: const LinkifyOptions(humanize: false),
onOpen: (url) => UrlLauncher(context, url.url).launchUrl(),
),
),
actions: [
AdaptiveDialogAction(
onPressed: () =>
Navigator.of(context).pop<OkCancelResult>(OkCancelResult.ok),
autofocus: true,
child: Text(okLabel ?? L10n.of(context).close),
),
],
}) => showAdaptiveDialog<OkCancelResult>(
context: context,
useRootNavigator: useRootNavigator,
builder: (context) => AlertDialog.adaptive(
title: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 256),
child: Text(title),
),
content: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 256),
child: message == null
? null
: SelectableLinkify(
text: message,
textScaleFactor: MediaQuery.textScalerOf(context).scale(1),
linkStyle: TextStyle(
color: Theme.of(context).colorScheme.primary,
decorationColor: Theme.of(context).colorScheme.primary,
),
options: const LinkifyOptions(humanize: false),
onOpen: (url) => UrlLauncher(context, url.url).launchUrl(),
),
),
actions: [
AdaptiveDialogAction(
onPressed: () =>
Navigator.of(context).pop<OkCancelResult>(OkCancelResult.ok),
autofocus: true,
child: Text(okLabel ?? L10n.of(context).close),
),
);
],
),
);

View file

@ -42,7 +42,7 @@ Future<String?> showTextInputDialog({
content: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 256),
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisSize: .min,
children: [
if (message != null)
SelectableLinkify(

View file

@ -22,15 +22,12 @@ class UserDialog extends StatelessWidget {
required BuildContext context,
required Profile profile,
bool noProfileWarning = false,
}) =>
showAdaptiveDialog(
context: context,
barrierDismissible: true,
builder: (context) => UserDialog(
profile,
noProfileWarning: noProfileWarning,
),
);
}) => showAdaptiveDialog(
context: context,
barrierDismissible: true,
builder: (context) =>
UserDialog(profile, noProfileWarning: noProfileWarning),
);
final Profile profile;
final bool noProfileWarning;
@ -41,7 +38,8 @@ class UserDialog extends StatelessWidget {
Widget build(BuildContext context) {
final client = Matrix.of(context).client;
final dmRoomId = client.getDirectChatFromUserId(profile.userId);
final displayname = profile.displayName ??
final displayname =
profile.displayName ??
profile.userId.localpart ??
L10n.of(context).user;
var copied = false;
@ -64,15 +62,15 @@ class UserDialog extends StatelessWidget {
final presenceText = presence.currentlyActive == true
? L10n.of(context).currentlyActive
: lastActiveTimestamp != null
? L10n.of(context).lastActiveAgo(
lastActiveTimestamp.localizedTimeShort(context),
)
: null;
? L10n.of(context).lastActiveAgo(
lastActiveTimestamp.localizedTimeShort(context),
)
: null;
return SingleChildScrollView(
child: Column(
spacing: 8,
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisSize: .min,
crossAxisAlignment: .stretch,
children: [
Center(
child: Avatar(
@ -81,9 +79,9 @@ class UserDialog extends StatelessWidget {
size: Avatar.defaultSize * 2,
onTap: avatar != null
? () => showDialog(
context: context,
builder: (_) => MxcImageViewer(avatar),
)
context: context,
builder: (_) => MxcImageViewer(avatar),
)
: null,
),
),
@ -112,8 +110,8 @@ class UserDialog extends StatelessWidget {
scale: hovered
? 1.33
: copied
? 1.25
: 1.0,
? 1.25
: 1.0,
child: Icon(
copied
? Icons.check_circle
@ -126,8 +124,9 @@ class UserDialog extends StatelessWidget {
),
TextSpan(text: profile.userId),
],
style: theme.textTheme.bodyMedium
?.copyWith(fontSize: 10),
style: theme.textTheme.bodyMedium?.copyWith(
fontSize: 10,
),
),
textAlign: TextAlign.center,
),
@ -144,8 +143,9 @@ class UserDialog extends StatelessWidget {
if (statusMsg != null)
SelectableLinkify(
text: statusMsg,
textScaleFactor:
MediaQuery.textScalerOf(context).scale(1),
textScaleFactor: MediaQuery.textScalerOf(
context,
).scale(1),
textAlign: TextAlign.center,
options: const LinkifyOptions(humanize: false),
linkStyle: TextStyle(