[pve-devel] [PATCH pve_flutter_frontend] ui: replace deprecated `withOpacity` function
Shan Shaji
s.shaji at proxmox.com
Mon Apr 28 17:45:12 CEST 2025
As of flutter v3.27 the `withOpacity` function
is deprecated. This patch replaces all occurrences
of `withOpacity` with `withValues` function.
Signed-off-by: Shan Shaji <s.shaji at proxmox.com>
---
lib/main.dart | 4 ++--
lib/pages/main_layout_slim.dart | 12 ++++++------
lib/utils/dot_indicator.dart | 2 +-
lib/widgets/proxmox_capacity_indicator.dart | 6 +++---
lib/widgets/proxmox_line_chart.dart | 2 +-
lib/widgets/pve_file_selector_widget.dart | 4 ++--
lib/widgets/pve_guest_migrate_widget.dart | 4 ++--
lib/widgets/pve_guest_overview_header.dart | 4 ++--
lib/widgets/pve_node_overview.dart | 4 ++--
lib/widgets/pve_rrd_chart_widget.dart | 3 ++-
lib/widgets/pve_task_log_expansiontile_widget.dart | 2 +-
11 files changed, 24 insertions(+), 23 deletions(-)
diff --git a/lib/main.dart b/lib/main.dart
index a985e3a..6b7d7f1 100644
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -130,7 +130,7 @@ class MyApp extends StatelessWidget {
foregroundColor: Colors.white, // onPrimary
),
textSelectionTheme: TextSelectionThemeData(
- selectionColor: ProxmoxColors.orange.withOpacity(0.4),
+ selectionColor: ProxmoxColors.orange.withValues(alpha: 0.4),
selectionHandleColor: ProxmoxColors.orange,
cursorColor: ProxmoxColors.orange,
),
@@ -173,7 +173,7 @@ class MyApp extends StatelessWidget {
),
scaffoldBackgroundColor: ProxmoxColors.grey,
textSelectionTheme: TextSelectionThemeData(
- selectionColor: ProxmoxColors.orange.withOpacity(0.4),
+ selectionColor: ProxmoxColors.orange.withValues(alpha: 0.4),
selectionHandleColor: ProxmoxColors.orange,
cursorColor: ProxmoxColors.orange,
),
diff --git a/lib/pages/main_layout_slim.dart b/lib/pages/main_layout_slim.dart
index 322bcac..58146ea 100644
--- a/lib/pages/main_layout_slim.dart
+++ b/lib/pages/main_layout_slim.dart
@@ -897,7 +897,7 @@ class _MobileResourceFilterSheet extends StatelessWidget {
color: Theme.of(context)
.colorScheme
.onSurface
- .withOpacity(0.75)),
+ .withValues(alpha: 0.75)),
),
value: state.typeFilter.contains('node'),
onChanged: (v) => rBloc.events.add(FilterResources(
@@ -912,7 +912,7 @@ class _MobileResourceFilterSheet extends StatelessWidget {
color: Theme.of(context)
.colorScheme
.onSurface
- .withOpacity(0.75)),
+ .withValues(alpha: 0.75)),
),
value: state.typeFilter.contains('qemu'),
onChanged: (v) => rBloc.events.add(FilterResources(
@@ -927,7 +927,7 @@ class _MobileResourceFilterSheet extends StatelessWidget {
color: Theme.of(context)
.colorScheme
.onSurface
- .withOpacity(0.75)),
+ .withValues(alpha: 0.75)),
),
value: state.typeFilter.contains('lxc'),
onChanged: (v) => rBloc.events.add(FilterResources(
@@ -942,7 +942,7 @@ class _MobileResourceFilterSheet extends StatelessWidget {
color: Theme.of(context)
.colorScheme
.onSurface
- .withOpacity(0.75)),
+ .withValues(alpha: 0.75)),
),
value: state.typeFilter.contains('storage'),
onChanged: (v) => rBloc.events.add(FilterResources(
@@ -971,7 +971,7 @@ class _MobileResourceFilterSheet extends StatelessWidget {
color: Theme.of(context)
.colorScheme
.onSurface
- .withOpacity(0.75)),
+ .withValues(alpha: 0.75)),
),
value: state.statusFilter
.contains(PveResourceStatusType.running),
@@ -988,7 +988,7 @@ class _MobileResourceFilterSheet extends StatelessWidget {
color: Theme.of(context)
.colorScheme
.onSurface
- .withOpacity(0.75)),
+ .withValues(alpha: 0.75)),
),
value: state.statusFilter
.contains(PveResourceStatusType.stopped),
diff --git a/lib/utils/dot_indicator.dart b/lib/utils/dot_indicator.dart
index c77e7e5..5096e24 100644
--- a/lib/utils/dot_indicator.dart
+++ b/lib/utils/dot_indicator.dart
@@ -36,7 +36,7 @@ class Dot extends StatelessWidget {
shape: BoxShape.circle,
boxShadow: [
BoxShadow(
- color: Colors.white.withOpacity(0.72),
+ color: Colors.white.withValues(alpha: 0.72),
blurRadius: shadowBlurRadius!,
spreadRadius: shadowSpreadRadius!,
offset: const Offset(0.0, 0.0))
diff --git a/lib/widgets/proxmox_capacity_indicator.dart b/lib/widgets/proxmox_capacity_indicator.dart
index 8e87ab0..ad95c29 100644
--- a/lib/widgets/proxmox_capacity_indicator.dart
+++ b/lib/widgets/proxmox_capacity_indicator.dart
@@ -45,7 +45,7 @@ class ProxmoxCapacityIndicator extends StatelessWidget {
: Theme.of(context)
.colorScheme
.onBackground
- .withOpacity(0.75))),
+ .withValues(alpha: 0.75))),
),
Text(usedValue,
style: TextStyle(
@@ -55,7 +55,7 @@ class ProxmoxCapacityIndicator extends StatelessWidget {
: Theme.of(context)
.colorScheme
.onBackground)
- .withOpacity(0.66),
+ .withValues(alpha: 0.66),
fontWeight: FontWeight.bold)),
],
),
@@ -65,7 +65,7 @@ class ProxmoxCapacityIndicator extends StatelessWidget {
(selected
? Theme.of(context).colorScheme.onPrimary
: Theme.of(context).colorScheme.onBackground)
- .withOpacity(0.66),
+ .withValues(alpha: 0.66),
fontWeight: FontWeight.bold))
],
),
diff --git a/lib/widgets/proxmox_line_chart.dart b/lib/widgets/proxmox_line_chart.dart
index 2b79e03..1e0b420 100644
--- a/lib/widgets/proxmox_line_chart.dart
+++ b/lib/widgets/proxmox_line_chart.dart
@@ -87,7 +87,7 @@ class ProxmoxLineChart extends CustomPainter {
text: TextSpan(
style: TextStyle(
color: textColor ?? Colors.white,
- backgroundColor: shadeColorBottom.withOpacity(0.75),
+ backgroundColor: shadeColorBottom.withValues(alpha: 0.75),
),
text: selectedLabel,
),
diff --git a/lib/widgets/pve_file_selector_widget.dart b/lib/widgets/pve_file_selector_widget.dart
index 87a547f..9770ff8 100644
--- a/lib/widgets/pve_file_selector_widget.dart
+++ b/lib/widgets/pve_file_selector_widget.dart
@@ -279,7 +279,7 @@ class PveStorageCard extends StatelessWidget {
color: (isSelected
? Theme.of(context).colorScheme.onPrimary
: Theme.of(context).colorScheme.onBackground)
- .withOpacity(0.75),
+ .withValues(alpha: 0.75),
fontWeight: FontWeight.bold,
),
maxLines: 1,
@@ -308,7 +308,7 @@ class PveStorageCard extends StatelessWidget {
color: Theme.of(context)
.colorScheme
.onBackground
- .withOpacity(0.75),
+ .withValues(alpha: 0.75),
fontWeight: FontWeight.bold,
),
),
diff --git a/lib/widgets/pve_guest_migrate_widget.dart b/lib/widgets/pve_guest_migrate_widget.dart
index 402fca0..d467dd7 100644
--- a/lib/widgets/pve_guest_migrate_widget.dart
+++ b/lib/widgets/pve_guest_migrate_widget.dart
@@ -63,7 +63,7 @@ class PveGuestMigrate extends StatelessWidget {
subtitle: Text(
migrateState.mode.name,
style: TextStyle(
- color: colorScheme.onPrimary.withOpacity(0.66)),
+ color: colorScheme.onPrimary.withValues(alpha: 0.66)),
),
),
ListTile(
@@ -75,7 +75,7 @@ class PveGuestMigrate extends StatelessWidget {
subtitle: Text(
migrateState.nodeID,
style: TextStyle(
- color: colorScheme.onPrimary.withOpacity(0.66)),
+ color: colorScheme.onPrimary.withValues(alpha: 0.66)),
),
),
Padding(
diff --git a/lib/widgets/pve_guest_overview_header.dart b/lib/widgets/pve_guest_overview_header.dart
index 2382f2d..1429ac1 100644
--- a/lib/widgets/pve_guest_overview_header.dart
+++ b/lib/widgets/pve_guest_overview_header.dart
@@ -37,7 +37,7 @@ class PveGuestOverviewHeader extends StatelessWidget {
@override
Widget build(BuildContext context) {
final haError = ha?.state == 'error';
- final fgColor = Theme.of(context).colorScheme.onPrimary.withOpacity(0.75);
+ final fgColor = Theme.of(context).colorScheme.onPrimary.withValues(alpha: 0.75);
return Container(
height: 250,
width: width,
@@ -175,7 +175,7 @@ class _PveGuestHeaderRRDPageViewState extends State<PveGuestHeaderRRDPageView> {
}
var rrdData = widget.rrdData! // safety: checked for null above...
.where((e) => e.time != null);
- final fgColor = Theme.of(context).colorScheme.onPrimary.withOpacity(0.75);
+ final fgColor = Theme.of(context).colorScheme.onPrimary.withValues(alpha: 0.75);
return ScrollConfiguration(
behavior: PVEScrollBehavior(),
child: PageView.builder(
diff --git a/lib/widgets/pve_node_overview.dart b/lib/widgets/pve_node_overview.dart
index 23f0edc..275a547 100644
--- a/lib/widgets/pve_node_overview.dart
+++ b/lib/widgets/pve_node_overview.dart
@@ -30,7 +30,7 @@ class PveNodeOverview extends StatelessWidget {
} else if (s.unitState == 'masked' || s.unitState == 'not-found') {
return Icon(
Icons.play_disabled,
- color: IconTheme.of(context).color!.withOpacity(0.75),
+ color: IconTheme.of(context).color!.withValues(alpha: 0.75),
);
} else {
return Icon(Icons.stop, color: Theme.of(context).colorScheme.error);
@@ -49,7 +49,7 @@ class PveNodeOverview extends StatelessWidget {
final status = state.status;
final rrd = state.rrdData.where((e) => e.time != null);
final fgColor =
- Theme.of(context).colorScheme.onPrimary.withOpacity(0.75);
+ Theme.of(context).colorScheme.onPrimary.withValues(alpha: 0.75);
return ColoredSafeArea(
child: Scaffold(
appBar: AppBar(
diff --git a/lib/widgets/pve_rrd_chart_widget.dart b/lib/widgets/pve_rrd_chart_widget.dart
index aa6406e..d61deea 100644
--- a/lib/widgets/pve_rrd_chart_widget.dart
+++ b/lib/widgets/pve_rrd_chart_widget.dart
@@ -55,7 +55,8 @@ class _PveRRDChartState extends State<PveRRDChart> {
final timeWindow = DateTime.fromMillisecondsSinceEpoch(data.last.x as int)
.difference(DateTime.fromMillisecondsSinceEpoch(data.first.x as int));
- final fgColor = Theme.of(context).colorScheme.onPrimary.withOpacity(0.85);
+ final fgColor =
+ Theme.of(context).colorScheme.onPrimary.withValues(alpha: 0.85);
return Column(
crossAxisAlignment: widget.titleAlginment,
children: <Widget>[
diff --git a/lib/widgets/pve_task_log_expansiontile_widget.dart b/lib/widgets/pve_task_log_expansiontile_widget.dart
index 6491b6b..de71187 100644
--- a/lib/widgets/pve_task_log_expansiontile_widget.dart
+++ b/lib/widgets/pve_task_log_expansiontile_widget.dart
@@ -86,7 +86,7 @@ class _PveTaskExpansionTileState extends State<PveTaskExpansionTile> {
? Text(DateFormat.Md().add_Hms().format(widget.task.endTime!),
style: TextStyle(color: headerColor))
: LinearProgressIndicator(
- backgroundColor: headerColor.withOpacity(0.5),
+ backgroundColor: headerColor.withValues(alpha: 0.5),
valueColor: AlwaysStoppedAnimation<Color>(headerColor),
),
trailing: Icon(
--
2.39.5
More information about the pve-devel
mailing list