From 0e94092df1d9345ae72a452ad899b98a2df4480e Mon Sep 17 00:00:00 2001 From: appflowy Date: Thu, 11 Nov 2021 14:04:41 +0800 Subject: [PATCH] [flutter]: fix bugs --- .../widgets/menu/widget/app/menu_app.dart | 2 +- .../menu/widget/app/section/section.dart | 28 +++++++++++-------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/app_flowy/lib/workspace/presentation/widgets/menu/widget/app/menu_app.dart b/app_flowy/lib/workspace/presentation/widgets/menu/widget/app/menu_app.dart index e5a7a95aad..ef106b0147 100644 --- a/app_flowy/lib/workspace/presentation/widgets/menu/widget/app/menu_app.dart +++ b/app_flowy/lib/workspace/presentation/widgets/menu/widget/app/menu_app.dart @@ -88,7 +88,7 @@ class _MenuAppState extends State { return MultiProvider( providers: [ChangeNotifierProvider.value(value: notifier)], child: Consumer(builder: (context, AppDataNotifier notifier, child) { - return const ViewSection().padding(vertical: 8); + return const ViewSection(); }), ); } diff --git a/app_flowy/lib/workspace/presentation/widgets/menu/widget/app/section/section.dart b/app_flowy/lib/workspace/presentation/widgets/menu/widget/app/section/section.dart index ef51c8a783..79c9d69955 100644 --- a/app_flowy/lib/workspace/presentation/widgets/menu/widget/app/section/section.dart +++ b/app_flowy/lib/workspace/presentation/widgets/menu/widget/app/section/section.dart @@ -37,18 +37,24 @@ class ViewSection extends StatelessWidget { } Widget _renderSectionItems(BuildContext context, List views) { - var viewWidgets = views.map( - (view) => ViewSectionItem( - view: view, - isSelected: _isViewSelected(context, view.id), - onSelected: (view) { - context.read().selectedView = view; - Provider.of(context, listen: false).selectedView = view; - }, - ).padding(vertical: 4), - ); + List viewWidgets = []; - return Column(children: viewWidgets.toList(growable: false)); + if (views.isNotEmpty) { + viewWidgets = views + .map( + (view) => ViewSectionItem( + view: view, + isSelected: _isViewSelected(context, view.id), + onSelected: (view) { + context.read().selectedView = view; + Provider.of(context, listen: false).selectedView = view; + }, + ).padding(vertical: 4), + ) + .toList(growable: false); + } + + return Column(children: viewWidgets); } bool _isViewSelected(BuildContext context, String viewId) {