From 73697b1ac33873e291095d01e7fa254db11b09df Mon Sep 17 00:00:00 2001 From: Gold87 <91761103+Gold872@users.noreply.github.com> Date: Wed, 8 Jan 2025 18:33:32 -0500 Subject: [PATCH] Fix color deprecation warnings (#193) Replaced `withOpacity` with `withValues` --- lib/src/models/view/builders/preset_builder.dart | 2 +- lib/src/pages/arm.dart | 6 +++--- lib/src/pages/view.dart | 16 ++++++++-------- lib/src/services/socket.dart | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/src/models/view/builders/preset_builder.dart b/lib/src/models/view/builders/preset_builder.dart index ba44f2844..a7a5da30e 100644 --- a/lib/src/models/view/builders/preset_builder.dart +++ b/lib/src/models/view/builders/preset_builder.dart @@ -15,6 +15,6 @@ class PresetBuilder extends ValueBuilder { @override void get value { /* Use [save] instead */ } - /// Calls [models.views.saveAsPreset] in views.dart + /// Calls `models.views.saveAsPreset` in views.dart void save() => models.views.saveAsPreset(nameController.text); } diff --git a/lib/src/pages/arm.dart b/lib/src/pages/arm.dart index a1c994e10..5791ba893 100644 --- a/lib/src/pages/arm.dart +++ b/lib/src/pages/arm.dart @@ -188,7 +188,7 @@ class ArmPainterSide extends CustomPainter { ]; final firstCirclePaint = Paint() - ..color = lineColors[0].withOpacity(opacity) + ..color = lineColors[0].withValues(alpha: opacity) ..style = PaintingStyle.fill; canvas.drawCircle(points[0], screen / 40, firstCirclePaint); @@ -196,7 +196,7 @@ class ArmPainterSide extends CustomPainter { // Draw lines based off joint position for (var i = 0; i < points.length - 1; i++) { final paint = Paint() - ..color = lineColors[i].withOpacity(opacity) + ..color = lineColors[i].withValues(alpha: opacity) ..strokeWidth = screen / 50; canvas.drawLine(points[i], points[i + 1], paint); } @@ -204,7 +204,7 @@ class ArmPainterSide extends CustomPainter { // Draw circles on each joint for (var i = 0; i < points.length - 1; i++) { final circlePaint = Paint() - ..color = lineColors[i].withOpacity(opacity) + ..color = lineColors[i].withValues(alpha: opacity) ..style = PaintingStyle.fill; canvas.drawCircle(points[i + 1], screen / 50, circlePaint); } diff --git a/lib/src/pages/view.dart b/lib/src/pages/view.dart index c604261a6..339305714 100644 --- a/lib/src/pages/view.dart +++ b/lib/src/pages/view.dart @@ -64,7 +64,7 @@ class DashboardView { /// An icon to indicate the status of the given camera. static Widget getCameraStatus(CameraName name) { if (!models.sockets.video.isConnected) { - return Icon(Icons.signal_wifi_off, color: Colors.black.withOpacity(0.5)); + return Icon(Icons.signal_wifi_off, color: Colors.black.withValues(alpha: 0.5)); } final status = models.video.feeds[name]!.details.status; const size = 12.0; @@ -93,37 +93,37 @@ class DashboardView { static final List uiViews = [ DashboardView( name: Routes.science, - iconFunc: () => Icon(Icons.science, color: Colors.black.withOpacity(0.5)), + iconFunc: () => Icon(Icons.science, color: Colors.black.withValues(alpha: 0.5)), builder: (context, index) => SciencePage(index: index), ), DashboardView( name: Routes.autonomy, - iconFunc: () => Icon(Icons.map, color: Colors.black.withOpacity(0.5)), + iconFunc: () => Icon(Icons.map, color: Colors.black.withValues(alpha: 0.5)), builder: (context, index) => MapPage(index: index), ), DashboardView( name: Routes.electrical, - iconFunc: () => Icon(Icons.bolt, color: Colors.black.withOpacity(0.5)), + iconFunc: () => Icon(Icons.bolt, color: Colors.black.withValues(alpha: 0.5)), builder: (context, index) => ElectricalPage(index: index), ), DashboardView( name: Routes.arm, - iconFunc: () => Icon(Icons.precision_manufacturing_outlined, color: Colors.black.withOpacity(0.5)), + iconFunc: () => Icon(Icons.precision_manufacturing_outlined, color: Colors.black.withValues(alpha: 0.5)), builder: (context, index) => ArmPage(index: index), ), DashboardView( name: Routes.drive, - iconFunc: () => Icon(Icons.drive_eta, color: Colors.black.withOpacity(0.5)), + iconFunc: () => Icon(Icons.drive_eta, color: Colors.black.withValues(alpha: 0.5)), builder: (context, index) => DrivePage(index: index), ), DashboardView( name: Routes.rocks, - iconFunc: () => Icon(Icons.landslide, color: Colors.black.withOpacity(0.5)), + iconFunc: () => Icon(Icons.landslide, color: Colors.black.withValues(alpha: 0.5)), builder: (context, index) => RocksPage(index: index), ), DashboardView( name: Routes.controllers, - iconFunc: () => Icon(Icons.sports_esports, color: Colors.black.withOpacity(0.5)), + iconFunc: () => Icon(Icons.sports_esports, color: Colors.black.withValues(alpha: 0.5)), builder: (context, index) => ControllersPage(index: index), ), ]; diff --git a/lib/src/services/socket.dart b/lib/src/services/socket.dart index 295949c33..b5e5be3a6 100644 --- a/lib/src/services/socket.dart +++ b/lib/src/services/socket.dart @@ -20,7 +20,7 @@ class DashboardSocket extends BurtSocket { /// Notifier for when the socket connects or disconnects final ValueNotifier connectionStatus = ValueNotifier(false); - /// Number of times to check heart beat per seconds based on [settings.network.connectionTimeout]. + /// Number of times to check heart beat per seconds based on `models.settings.network.connectionTimeout`. double get frequency => models.settings.network.connectionTimeout; /// Listens for incoming messages on a UDP socket and sends heartbeats to the [device].