From 3b1e91811791e5831ff84362d2d1732a633d0a21 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Mon, 20 Jan 2025 01:43:11 +0800 Subject: [PATCH] :bug: Fix side nav cause render error --- lib/widgets/navigation/app_rail_navigation.dart | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/widgets/navigation/app_rail_navigation.dart b/lib/widgets/navigation/app_rail_navigation.dart index b5376a6..17df855 100644 --- a/lib/widgets/navigation/app_rail_navigation.dart +++ b/lib/widgets/navigation/app_rail_navigation.dart @@ -18,9 +18,7 @@ class _AppRailNavigationState extends State { void initState() { super.initState(); WidgetsBinding.instance.addPostFrameCallback((_) { - context - .read() - .autoDetectIndex(GoRouter.maybeOf(context)); + context.read().autoDetectIndex(GoRouter.maybeOf(context)); }); } @@ -31,11 +29,11 @@ class _AppRailNavigationState extends State { return ListenableBuilder( listenable: nav, builder: (context, _) { - final destinations = - nav.destinations.where((ele) => ele.isPinned).toList(); + final destinations = nav.destinations.where((ele) => ele.isPinned).toList(); return NavigationRail( - selectedIndex: nav.currentIndex, + selectedIndex: + nav.currentIndex != null && nav.currentIndex! < nav.pinnedDestinationCount ? nav.currentIndex : null, destinations: [ ...destinations.where((ele) => ele.isPinned).map((ele) { return NavigationRailDestination(