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

@ -70,9 +70,7 @@ class _StreamView extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
decoration: const BoxDecoration(
color: Colors.black54,
),
decoration: const BoxDecoration(color: Colors.black54),
child: Stack(
alignment: Alignment.center,
children: <Widget>[
@ -133,9 +131,8 @@ class Calling extends StatefulWidget {
class MyCallingPage extends State<Calling> {
Room? get room => call.room;
String get displayName => call.room.getLocalizedDisplayname(
MatrixLocals(L10n.of(widget.context)),
);
String get displayName =>
call.room.getLocalizedDisplayname(MatrixLocals(L10n.of(widget.context)));
String get callId => widget.callId;
@ -219,10 +216,7 @@ class MyCallingPage extends State<Calling> {
}
void cleanUp() {
Timer(
const Duration(seconds: 2),
() => widget.onClear?.call(),
);
Timer(const Duration(seconds: 2), () => widget.onClear?.call());
if (call.type == CallType.kVideo) {
try {
unawaited(WakelockPlus.disable());
@ -295,8 +289,9 @@ class MyCallingPage extends State<Calling> {
androidNotificationOptions: AndroidNotificationOptions(
channelId: 'notification_channel_id',
channelName: 'Foreground Notification',
channelDescription:
L10n.of(widget.context).foregroundServiceRunning,
channelDescription: L10n.of(
widget.context,
).foregroundServiceRunning,
),
iosNotificationOptions: const IOSNotificationOptions(),
foregroundTaskOptions: ForegroundTaskOptions(
@ -434,9 +429,7 @@ class MyCallingPage extends State<Calling> {
hangupButton,
];
case CallState.kEnded:
return <Widget>[
hangupButton,
];
return <Widget>[hangupButton];
case CallState.kFledgling:
case CallState.kWaitLocalMedia:
case CallState.kCreateOffer:
@ -458,28 +451,20 @@ class MyCallingPage extends State<Calling> {
if (call.localHold || call.remoteOnHold) {
var title = '';
if (call.localHold) {
title = '${call.room.getLocalizedDisplayname(
MatrixLocals(L10n.of(widget.context)),
)} held the call.';
title =
'${call.room.getLocalizedDisplayname(MatrixLocals(L10n.of(widget.context)))} held the call.';
} else if (call.remoteOnHold) {
title = 'You held the call.';
}
stackWidgets.add(
Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisAlignment: .center,
children: [
const Icon(
Icons.pause,
size: 48.0,
color: Colors.white,
),
const Icon(Icons.pause, size: 48.0, color: Colors.white),
Text(
title,
style: const TextStyle(
color: Colors.white,
fontSize: 24.0,
),
style: const TextStyle(color: Colors.white, fontSize: 24.0),
),
],
),
@ -488,7 +473,8 @@ class MyCallingPage extends State<Calling> {
return stackWidgets;
}
var primaryStream = call.remoteScreenSharingStream ??
var primaryStream =
call.remoteScreenSharingStream ??
call.localScreenSharingStream ??
call.remoteUserMediaStream ??
call.localUserMediaStream;
@ -527,8 +513,10 @@ class MyCallingPage extends State<Calling> {
SizedBox(
width: _localVideoWidth,
height: _localVideoHeight,
child:
_StreamView(remoteUserMediaStream!, matrixClient: widget.client),
child: _StreamView(
remoteUserMediaStream!,
matrixClient: widget.client,
),
),
);
secondaryStreamViews.add(const SizedBox(height: 10));
@ -569,9 +557,7 @@ class MyCallingPage extends State<Calling> {
child: Container(
width: _localVideoWidth,
margin: _localVideoMargin,
child: Column(
children: secondaryStreamViews,
),
child: Column(children: secondaryStreamViews),
),
),
);
@ -592,16 +578,14 @@ class MyCallingPage extends State<Calling> {
width: 320.0,
height: 150.0,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
mainAxisAlignment: .spaceAround,
children: _buildActionButtons(isFloating),
),
),
body: OrientationBuilder(
builder: (BuildContext context, Orientation orientation) {
return Container(
decoration: const BoxDecoration(
color: Colors.black87,
),
decoration: const BoxDecoration(color: Colors.black87),
child: Stack(
children: [
..._buildContent(orientation, isFloating),

View file

@ -9,10 +9,7 @@ class PIPView extends StatefulWidget {
final double? floatingHeight;
final bool avoidKeyboard;
final Widget Function(
BuildContext context,
bool isFloating,
) builder;
final Widget Function(BuildContext context, bool isFloating) builder;
const PIPView({
super.key,
@ -95,10 +92,7 @@ class PIPViewState extends State<PIPView> with TickerProviderStateMixin {
void _onPanUpdate(DragUpdateDetails details) {
if (!_isDragging) return;
setState(() {
_dragOffset = _dragOffset.translate(
details.delta.dx,
details.delta.dy,
);
_dragOffset = _dragOffset.translate(details.delta.dx, details.delta.dy);
});
}
@ -182,9 +176,7 @@ class PIPViewState extends State<PIPView> with TickerProviderStateMixin {
_dragAnimationController,
]),
builder: (context, child) {
final animationCurve = CurveTween(
curve: Curves.easeInOutQuad,
);
final animationCurve = CurveTween(curve: Curves.easeInOutQuad);
final dragAnimationValue = animationCurve.transform(
_dragAnimationController.value,
);
@ -265,21 +257,13 @@ class PIPViewState extends State<PIPView> with TickerProviderStateMixin {
}
}
enum PIPViewCorner {
topLeft,
topRight,
bottomLeft,
bottomRight,
}
enum PIPViewCorner { topLeft, topRight, bottomLeft, bottomRight }
class _CornerDistance {
final PIPViewCorner corner;
final double distance;
_CornerDistance({
required this.corner,
required this.distance,
});
_CornerDistance({required this.corner, required this.distance});
}
PIPViewCorner _calculateNearestCorner({
@ -288,15 +272,9 @@ PIPViewCorner _calculateNearestCorner({
}) {
_CornerDistance calculateDistance(PIPViewCorner corner) {
final distance = offsets[corner]!
.translate(
-offset.dx,
-offset.dy,
)
.translate(-offset.dx, -offset.dy)
.distanceSquared;
return _CornerDistance(
corner: corner,
distance: distance,
);
return _CornerDistance(corner: corner, distance: distance);
}
final distances = PIPViewCorner.values.map(calculateDistance).toList();