From 1671c90a78205595ecd0d4ec6d32462082878557 Mon Sep 17 00:00:00 2001 From: Freek van de Ven Date: Mon, 5 Aug 2024 14:56:51 +0200 Subject: [PATCH] fix: remove template button when there are templates available --- .../lib/src/ui/widgets/template_legend.dart | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/flutter_availability/lib/src/ui/widgets/template_legend.dart b/packages/flutter_availability/lib/src/ui/widgets/template_legend.dart index 0130661..ab31e3d 100644 --- a/packages/flutter_availability/lib/src/ui/widgets/template_legend.dart +++ b/packages/flutter_availability/lib/src/ui/widgets/template_legend.dart @@ -48,7 +48,6 @@ class _TemplateLegendState extends State { false; var templatesVisible = templatesAvailable && _templateDrawerOpen; - if (!templatesAvailable && !featureSet.require(AvailabilityFeature.templates)) { return const SizedBox.shrink(); @@ -86,7 +85,7 @@ class _TemplateLegendState extends State { thickness: 1, ); - if (_templateDrawerOpen && !templatesLoading) { + if (_templateDrawerOpen && templatesAvailable) { body = Container( constraints: const BoxConstraints(maxHeight: 152), child: SingleChildScrollView( @@ -161,8 +160,8 @@ class _TemplateLegendState extends State { translations.templateLegendTitle, style: textTheme.titleMedium, ), - if ((templatesAvailable && !templatesLoading) || - _templateDrawerOpen) ...[ + if (templatesAvailable || + (_templateDrawerOpen && templatesLoading)) ...[ Icon( _templateDrawerOpen ? Icons.arrow_drop_up @@ -195,7 +194,9 @@ class _TemplateLegendState extends State { if (templatesLoading) ...[ options.loadingIndicatorBuilder(context), ] else ...[ - createNewTemplateButton, + if (templates.isEmpty) ...[ + createNewTemplateButton, + ], ], ], ],