From 1a68c362cb07054c0dfd0e939d102f9451fe672d Mon Sep 17 00:00:00 2001 From: BHznJNs <441768875@qq.com> Date: Wed, 26 Feb 2025 11:12:55 +0800 Subject: [PATCH] drawer highlight bug fixed --- lib/components/drawer.dart | 6 +++++- lib/main.dart | 12 ++---------- pubspec.yaml | 2 +- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/lib/components/drawer.dart b/lib/components/drawer.dart index c0d699e..d83500b 100644 --- a/lib/components/drawer.dart +++ b/lib/components/drawer.dart @@ -35,7 +35,11 @@ class ScaffoldDrawer extends StatelessWidget { _DrawerItemData(l10n.drawer_galleryPage, '/gallery' , Icons.collections_bookmark_outlined, Icons.collections_bookmark), _DrawerItemData(l10n.drawer_settingPage, '/settings', Icons.settings_outlined , Icons.settings ), ]; - final currentRoute = ModalRoute.of(context)?.settings.name ?? '/create'; + final currentRoute = (() { + final routeName = ModalRoute.of(context)?.settings.name; + if (routeName == null || routeName == '/') return '/create'; + return routeName; + })(); return Drawer( child: SafeArea( child: Column( diff --git a/lib/main.dart b/lib/main.dart index 12e1d52..6a636af 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -135,7 +135,7 @@ class MyAppState extends State { seedColor: colorTheme, brightness: Brightness.dark, ); - final routes = { + final routes = { '/create': (context) => ScaffoldWithDrawer( title: S.of(context)?.drawer_createPage ?? 'Create a Link', body: CreatePage(), @@ -186,15 +186,7 @@ class MyAppState extends State { ), ), themeMode: themeProvider.theme.toThemeMode(), - home: Builder( - builder: (context) { - return ScaffoldWithDrawer( - title: S.of(context)?.drawer_createPage ?? 'Create a Link', - body: CreatePage(), - drawer: sharedDrawer, - ); - }, - ), + home: Builder(builder: routes['/create']!), routes: routes, ); } diff --git a/pubspec.yaml b/pubspec.yaml index 7be71c8..8463e78 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # In Windows, build-name is used as the major, minor, and patch parts # of the product and file versions while build-number is used as the build suffix. -version: 1.1.2 +version: 1.1.3 environment: sdk: ^3.6.1