From 404618c2a56f956646c9ac4f9ad77c72ad8a94de Mon Sep 17 00:00:00 2001 From: Codel1417 Date: Thu, 6 Jun 2024 20:40:28 -0400 Subject: [PATCH] Fix error with ota warning when no gear are known --- lib/Frontend/Widgets/tutorial_card.dart | 57 ++++++++++++++----------- 1 file changed, 31 insertions(+), 26 deletions(-) diff --git a/lib/Frontend/Widgets/tutorial_card.dart b/lib/Frontend/Widgets/tutorial_card.dart index a2348e77..d6f24bca 100644 --- a/lib/Frontend/Widgets/tutorial_card.dart +++ b/lib/Frontend/Widgets/tutorial_card.dart @@ -37,32 +37,37 @@ class GearOutOfDateWarning extends ConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { - return MultiValueListenableBuilder( - valueListenables: ref - .watch(knownDevicesProvider) - .values - .map( - (e) => e.mandatoryOtaRequired, - ) - .toList(), - builder: (context, values, child) { - if (values.contains(true)) { - Color color = Theme.of(context).colorScheme.primary; - return BaseCard( - color: color, - child: Center( - child: Padding( - padding: const EdgeInsets.all(16.0), - child: Text( - featureLimitedOtaRequiredLabel(), - style: Theme.of(context).textTheme.labelLarge!.copyWith(color: getTextColor(color)), + List> valueNotifiers = ref + .watch(knownDevicesProvider) + .values + .map( + (e) => e.mandatoryOtaRequired, + ) + .toList(); + if (valueNotifiers.isNotEmpty) { + return MultiValueListenableBuilder( + valueListenables: valueNotifiers, + builder: (context, values, child) { + if (values.contains(true)) { + Color color = Theme.of(context).colorScheme.primary; + return BaseCard( + color: color, + child: Center( + child: Padding( + padding: const EdgeInsets.all(16.0), + child: Text( + featureLimitedOtaRequiredLabel(), + style: Theme.of(context).textTheme.labelLarge!.copyWith(color: getTextColor(color)), + ), ), - ), - )); - } else { - return Container(); - } - }, - ); + )); + } else { + return Container(); + } + }, + ); + } else { + return Container(); + } } }