public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH pve_flutter_frontend] fix: ui: null check operator used on null value error on resource tab
@ 2025-05-20 15:04 Shan Shaji
  2025-05-21 12:43 ` [pve-devel] applied: " Dominik Csapak
  0 siblings, 1 reply; 2+ messages in thread
From: Shan Shaji @ 2025-05-20 15:04 UTC (permalink / raw)
  To: pve-devel

The issue occurred because the null assertion operator (!) was used on
the `template`` variable, which was potentially null. When the
`PveGuestIcon` widget started rendering, it first checked the if
condition inside the build method. If the `template` variable was
null at that point, Flutter threw an error because the null
assertion operator (!) was used, asserting that the variable
was not null.

To fix this, the bang operator (!) and the nullable operator (?)
is removed. Additionally, in the `PveGuestListTile`, a default
value of `false` is assigned when the `template` value is null.

Summary of the changes:
- Removed the bang operator (!) from the `template` variable
  in `PveGuestIcon`.
- Removed the nullable operator (?).
- Assigned a default value of false to `template` in `PveGuestListTile`
  when it's null.

Signed-off-by: Shan Shaji <s.shaji@proxmox.com>
---
 lib/pages/main_layout_slim.dart        | 2 +-
 lib/widgets/pve_guest_icon_widget.dart | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/pages/main_layout_slim.dart b/lib/pages/main_layout_slim.dart
index ac5a6f9..04e21e7 100644
--- a/lib/pages/main_layout_slim.dart
+++ b/lib/pages/main_layout_slim.dart
@@ -694,7 +694,7 @@ class PveGuestListTile extends StatelessWidget {
     return ListTile(
       leading: PveGuestIcon(
         type: resource.type,
-        template: resource.template,
+        template: resource.template ?? false,
         status: status,
       ),
       title: Text(resource.displayName),
diff --git a/lib/widgets/pve_guest_icon_widget.dart b/lib/widgets/pve_guest_icon_widget.dart
index 4dd7a58..1cdee7e 100644
--- a/lib/widgets/pve_guest_icon_widget.dart
+++ b/lib/widgets/pve_guest_icon_widget.dart
@@ -4,7 +4,7 @@ import 'package:pve_flutter_frontend/utils/renderers.dart';
 
 class PveGuestIcon extends StatelessWidget {
   final String type;
-  final bool? template;
+  final bool template;
   final PveResourceStatusType? status;
   final Color color;
   final Color templateColor;
@@ -20,7 +20,7 @@ class PveGuestIcon extends StatelessWidget {
 
   @override
   Widget build(BuildContext context) {
-    if (template!) {
+    if (template) {
       return SizedBox(
         height: 24,
         width: 36,
-- 
2.39.5



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [pve-devel] applied: [PATCH pve_flutter_frontend] fix: ui: null check operator used on null value error on resource tab
  2025-05-20 15:04 [pve-devel] [PATCH pve_flutter_frontend] fix: ui: null check operator used on null value error on resource tab Shan Shaji
@ 2025-05-21 12:43 ` Dominik Csapak
  0 siblings, 0 replies; 2+ messages in thread
From: Dominik Csapak @ 2025-05-21 12:43 UTC (permalink / raw)
  To: pve-devel

On 5/20/25 17:04, Shan Shaji wrote:
> The issue occurred because the null assertion operator (!) was used on
> the `template`` variable, which was potentially null. When the
> `PveGuestIcon` widget started rendering, it first checked the if
> condition inside the build method. If the `template` variable was
> null at that point, Flutter threw an error because the null
> assertion operator (!) was used, asserting that the variable
> was not null.
> 
> To fix this, the bang operator (!) and the nullable operator (?)
> is removed. Additionally, in the `PveGuestListTile`, a default
> value of `false` is assigned when the `template` value is null.
> 
> Summary of the changes:
> - Removed the bang operator (!) from the `template` variable
>    in `PveGuestIcon`.
> - Removed the nullable operator (?).
> - Assigned a default value of false to `template` in `PveGuestListTile`
>    when it's null.
> 
> Signed-off-by: Shan Shaji <s.shaji@proxmox.com>
> ---
>   lib/pages/main_layout_slim.dart        | 2 +-
>   lib/widgets/pve_guest_icon_widget.dart | 4 ++--
>   2 files changed, 3 insertions(+), 3 deletions(-)
> 
>

applied, thanks!

I fixed up the commit message with a small explanation
how one could run into this


_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-05-21 12:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-05-20 15:04 [pve-devel] [PATCH pve_flutter_frontend] fix: ui: null check operator used on null value error on resource tab Shan Shaji
2025-05-21 12:43 ` [pve-devel] applied: " Dominik Csapak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal