]> git.proxmox.com Git - flutter/pve_flutter_frontend.git/commitdiff
tree-wide: prefer const declarations and constructors, avoid null in if-null
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 11 Apr 2024 07:58:29 +0000 (09:58 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 11 Apr 2024 10:37:44 +0000 (12:37 +0200)
Adapted using `dart fix --code` with following lints:
- prefer_const_constructors
- prefer_const_declarations
- unnecessary_null_in_if_null_operators

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
lib/main.dart
lib/pages/main_layout_slim.dart
lib/utils/proxmox_colors.dart
lib/widgets/proxmox_cluster_visualizer.dart
lib/widgets/pve_lxc_overview.dart
lib/widgets/pve_node_overview.dart
lib/widgets/pve_qemu_overview.dart
lib/widgets/pve_rrd_chart_widget.dart
lib/widgets/pve_subscription_alert_dialog.dart

index f2152096c15977957bccdfcbdc2fc67bb9a51915..804e7bd5233256ce31ecee36364a0f329a2db08c 100644 (file)
@@ -307,12 +307,12 @@ class MyApp extends StatelessWidget {
         onGenerateRoute: (context) {
           if (authbloc!.state.value is Uninitialized) {
             return MaterialPageRoute(
-              builder: (context) => PveSplashScreen(),
+              builder: (context) => const PveSplashScreen(),
             );
           }
           if (sharedPreferences.getBool('showWelcomeScreen') ?? true) {
             return MaterialPageRoute(
-              builder: (context) => PveWelcome(),
+              builder: (context) => const PveWelcome(),
             );
           }
 
@@ -464,8 +464,8 @@ class MyApp extends StatelessWidget {
                     //TODO add a wide layout option here when it's ready
                     child: ProxmoxLayoutBuilder(
                       builder: (context, layout) => layout != ProxmoxLayout.slim
-                          ? MainLayoutSlim()
-                          : MainLayoutSlim(),
+                          ? const MainLayoutSlim()
+                          : const MainLayoutSlim(),
                     ),
                   ),
                 );
@@ -474,7 +474,7 @@ class MyApp extends StatelessWidget {
                 return MaterialPageRoute(
                   settings: context,
                   builder: (context) {
-                    return NotFoundPage();
+                    return const NotFoundPage();
                   },
                 );
             }
@@ -482,7 +482,7 @@ class MyApp extends StatelessWidget {
           return MaterialPageRoute(
             settings: context,
             builder: (context) {
-              return NotFoundPage();
+              return const NotFoundPage();
             },
           );
         },
index 7a6264ccdb3d1ebc9d5505c02b6f51c2e3ad988e..c2fa9ac6122c3a1f35b62b0dc5cafc8db527ba61 100644 (file)
@@ -83,16 +83,16 @@ class _MainLayoutSlimState extends State<MainLayoutSlim> {
             if (snapshot.hasData) {
               switch (snapshot.data) {
                 case 0:
-                  return MobileDashboard();
+                  return const MobileDashboard();
                   break;
                 case 1:
-                  return MobileResourceOverview();
+                  return const MobileResourceOverview();
                   break;
                 case 2:
                   Provider.of<PveAccessManagementBloc>(context)
                       .events
                       .add(LoadUsers());
-                  return MobileAccessManagement();
+                  return const MobileAccessManagement();
 
                   break;
                 default:
@@ -251,7 +251,7 @@ class MobileDashboard extends StatelessWidget {
                           ),
                           onPressed: () => showDialog(
                             context: context,
-                            builder: (c) => PveSubscriptionAlertDialog(),
+                            builder: (c) => const PveSubscriptionAlertDialog(),
                           ),
                         ),
                       Padding(
@@ -547,7 +547,7 @@ class MobileDashboard extends StatelessWidget {
               ]);
             }),
       ]),
-      bottomNavigationBar: PveMobileBottomNavigationbar(),
+      bottomNavigationBar: const PveMobileBottomNavigationbar(),
     );
   }
 }
@@ -611,7 +611,7 @@ class MobileResourceOverview extends StatelessWidget {
                 onChanged: (filter) =>
                     rBloc.events.add(FilterResources(nameFilter: filter)),
               ),
-              actions: <Widget>[AppBarFilterIconButton()],
+              actions: <Widget>[const AppBarFilterIconButton()],
             ),
             body: ListView.separated(
               itemCount: fResources.length,
@@ -664,7 +664,7 @@ class MobileResourceOverview extends StatelessWidget {
                 );
               },
             ),
-            bottomNavigationBar: PveMobileBottomNavigationbar(),
+            bottomNavigationBar: const PveMobileBottomNavigationbar(),
           )),
         );
       },
@@ -1243,7 +1243,7 @@ class MobileAccessManagement extends StatelessWidget {
                     }),
               ]);
             }),
-        bottomNavigationBar: PveMobileBottomNavigationbar(),
+        bottomNavigationBar: const PveMobileBottomNavigationbar(),
       ),
     );
   }
index d26a9b4bc229320ce41d5fbfbcc166c2c34ef99e..f751f50e18718603caa320f393e57b666525cf27 100644 (file)
@@ -1,42 +1,41 @@
 import 'package:flutter/material.dart';
 
 class ProxmoxColors {
-  static final Color orange = const Color(0xFFE57000);
-  static final Color black = const Color(0xFF000000);
-  static final Color supportLightOrange = const Color(0xFFFF9100);
-  static final Color supportBlue = const Color(0xFF00617F);
-  static final Color supportDarkGrey = const Color(0xFF464D4D);
+  static const Color orange = Color(0xFFE57000);
+  static const Color black = Color(0xFF000000);
+  static const Color supportLightOrange = Color(0xFFFF9100);
+  static const Color supportBlue = Color(0xFF00617F);
+  static const Color supportDarkGrey = Color(0xFF464D4D);
 
   // generated from material colors spec
-  static final Color blue900 = const Color(0xFF003951);
-  static final Color blue800 = const Color(0xFF004e69);
-  static final Color blue700 =
-      const Color(0xFF00617F); // actual proxmox support blue
-  static final Color blue600 = const Color(0xFF1b7696);
-  static final Color blue500 = const Color(0xFF2c85a8);
-  static final Color blue400 = const Color(0xFF4e98b9);
-  static final Color blue300 = const Color(0xFF6aaccb);
-  static final Color blue200 = const Color(0xFF8cc5e2);
-  static final Color blue100 = const Color(0xFFabdff7);
-  static final Color blue50 = const Color(0xFFcdf4ff);
+  static const Color blue900 = Color(0xFF003951);
+  static const Color blue800 = Color(0xFF004e69);
+  static const Color blue700 = Color(0xFF00617F); // actual proxmox support blue
+  static const Color blue600 = Color(0xFF1b7696);
+  static const Color blue500 = Color(0xFF2c85a8);
+  static const Color blue400 = Color(0xFF4e98b9);
+  static const Color blue300 = Color(0xFF6aaccb);
+  static const Color blue200 = Color(0xFF8cc5e2);
+  static const Color blue100 = Color(0xFFabdff7);
+  static const Color blue50 = Color(0xFFcdf4ff);
 
   // chosen with the values.js lib, but still needs to be weeded out and
   // may get improved.
-  static final Color grey = const Color(0xFF464D4D);
-  static final Color greyTint20 = const Color(0xFF6b7171);
-  static final Color greyTint40 = const Color(0xFF909494);
-  static final Color greyTint60 = const Color(0xFFb5b8b8);
-  static final Color greyTint80 = const Color(0xFFdadbdb);
-  static final Color greyShade20 = const Color(0xFF383e3e);
-  static final Color greyShade40 = const Color(0xFF2a2e2e);
-  static final Color greyShade60 = const Color(0xFF1c1f1f);
-  static final Color greyShade80 = const Color(0xFF0e0f0f);
+  static const Color grey = Color(0xFF464D4D);
+  static const Color greyTint20 = Color(0xFF6b7171);
+  static const Color greyTint40 = Color(0xFF909494);
+  static const Color greyTint60 = Color(0xFFb5b8b8);
+  static const Color greyTint80 = Color(0xFFdadbdb);
+  static const Color greyShade20 = Color(0xFF383e3e);
+  static const Color greyShade40 = Color(0xFF2a2e2e);
+  static const Color greyShade60 = Color(0xFF1c1f1f);
+  static const Color greyShade80 = Color(0xFF0e0f0f);
 
-  static final Color supportGrey = const Color(0xFFABBABA);
-  static final Color supportGreyTint25 = const Color(0xFFc0cbcb);
-  static final Color supportGreyTint50 = const Color(0xFFd5dddd);
-  static final Color supportGreyTint75 = const Color(0xFFeaeeee);
-  static final Color supportGreyShade25 = const Color(0xFF808c8c);
-  static final Color supportGreyShade50 = const Color(0xFF565d5d);
-  static final Color supportGreyShade75 = const Color(0xFF2b2f2f);
+  static const Color supportGrey = Color(0xFFABBABA);
+  static const Color supportGreyTint25 = Color(0xFFc0cbcb);
+  static const Color supportGreyTint50 = Color(0xFFd5dddd);
+  static const Color supportGreyTint75 = Color(0xFFeaeeee);
+  static const Color supportGreyShade25 = Color(0xFF808c8c);
+  static const Color supportGreyShade50 = Color(0xFF565d5d);
+  static const Color supportGreyShade75 = Color(0xFF2b2f2f);
 }
index 64348fc0d10d7fde18ce3074e093f93301bff321..50f58cb3bd075d18732f29ec9120deaa9679e23e 100644 (file)
@@ -46,7 +46,7 @@ class ProxmoxClusterVisualizer extends CustomPainter {
     //   ..style = PaintingStyle.fill
     //   ..color = Colors.green;
     // canvas.drawCircle(Offset(x, y), seedRadius, paint);
-    final icon = Icons.storage;
+    const icon = Icons.storage;
     var builder = ui.ParagraphBuilder(
         ui.ParagraphStyle(fontFamily: icon.fontFamily, fontSize: 60))
       ..addText(String.fromCharCode(icon.codePoint));
index 40e249d74ce248177e912470164b42862f57b38c..5bf7f3142ff745b47c2e436a5d29558a3e2714ef 100644 (file)
@@ -121,7 +121,7 @@ class PveLxcOverview extends StatelessWidget {
                                   )
                                   ..events.add(LoadTasks()),
                                 dispose: (context, bloc) => bloc.dispose(),
-                                child: PveTaskLog(),
+                                child: const PveTaskLog(),
                               ),
                             );
                           }
@@ -297,7 +297,7 @@ class PveLxcOverview extends StatelessWidget {
           ),
           dispose: (context, PveTaskLogViewerBloc bloc) => bloc.dispose(),
         )
-      ], child: PveGuestMigrate()),
+      ], child: const PveGuestMigrate()),
     );
   }
 
index e1495b6950c07ac140587b05a0d1b7e0282dcc5e..594887b7f016ed588517422c0b5cf96242e4fca5 100644 (file)
@@ -169,7 +169,7 @@ class PveNodeOverview extends StatelessWidget {
                                 init: PveTaskLogState.init(nodeID),
                               )..events.add(LoadTasks()),
                               dispose: (context, bloc) => bloc.dispose(),
-                              child: PveTaskLog(),
+                              child: const PveTaskLog(),
                             ),
                           ),
                         );
index 73ffdd1e2de2f3d0331cb1a62f3a1580f109334c..d7046cc10264ef3954696172cef2d90f278ee094 100644 (file)
@@ -123,7 +123,7 @@ class PveQemuOverview extends StatelessWidget {
                                   )
                                   ..events.add(LoadTasks()),
                                 dispose: (context, bloc) => bloc.dispose(),
-                                child: PveTaskLog(),
+                                child: const PveTaskLog(),
                               ),
                             );
                           }
@@ -311,7 +311,7 @@ class PveQemuOverview extends StatelessWidget {
           ),
           dispose: (context, PveTaskLogViewerBloc bloc) => bloc.dispose(),
         )
-      ], child: PveGuestMigrate()),
+      ], child: const PveGuestMigrate()),
       transitionsBuilder: (context, animation, secondaryAnimation, child) {
         return ScaleTransition(
           scale: Tween<double>(
index b25a54b49d792af2cf4e4b3389689ef6976ca13f..cfd07f7d488fe83a7c27f6667e3eade0ddbc843a 100644 (file)
@@ -60,8 +60,8 @@ class _PveRRDChartState extends State<PveRRDChart> {
       crossAxisAlignment: widget.titleAlginment,
       children: <Widget>[
         Container(
-          width: widget.titleWidth ?? null,
-          padding: widget.titlePadding ?? null,
+          width: widget.titleWidth,
+          padding: widget.titlePadding,
           child: ListTile(
             leading: widget.icon,
             title: Text(
index da8d15ed5161ba5570b84ca7fe0eb7b8f7d617b6..fbc752bf4a96aa7253c2d0595354d8c82055ac8a 100644 (file)
@@ -16,7 +16,7 @@ class PveSubscriptionAlertDialog extends StatelessWidget {
       actions: [
         TextButton(
             onPressed: () async {
-              final url = 'https://www.proxmox.com/proxmox-ve/pricing';
+              const url = 'https://www.proxmox.com/proxmox-ve/pricing';
               if (await canLaunch(url)) {
                 await launch(url);
               } else {