fix: Drawer pop() after item is selected#629
fix: Drawer pop() after item is selected#629chetanr25 wants to merge 1 commit intoCCExtractor:mainfrom
Conversation
📝 WalkthroughWalkthroughThe pull request adds automatic drawer closure on navigation within the nav drawer component. The change calls Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment Tip You can customize the high-level summary generated by CodeRabbit.Configure the |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
lib/app/modules/home/views/nav_drawer.dart (1)
89-90: Consider extracting a shared “close drawer then navigate” helper.The same close-then-route sequence is repeated in several handlers, which makes future edits easy to miss.
♻️ Suggested refactor
@@ `@override` Widget build(BuildContext context) { + void closeDrawer() => Navigator.of(context).pop(); + @@ onTap: () { - Navigator.of(context).pop(); + closeDrawer(); Get.toNamed(Routes.PROFILE); }, @@ onTap: () { - Navigator.of(context).pop(); + closeDrawer(); Get.toNamed(Routes.REPORTS); }, @@ onTap: () { - Navigator.of(context).pop(); + closeDrawer(); Get.to(() => ReportsHomeTaskc()); }, @@ onTap: () { - Navigator.of(context).pop(); + closeDrawer(); Get.to(() => ReportsHomeReplica()); }, @@ onTap: () { - Navigator.of(context).pop(); + closeDrawer(); Get.toNamed(Routes.ABOUT); }, @@ onTap: () async { - Navigator.of(context).pop(); + closeDrawer(); final SharedPreferences prefs = await SharedPreferences.getInstance();Also applies to: 104-106, 120-122, 136-138, 149-151, 161-172
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@lib/app/modules/home/views/nav_drawer.dart` around lines 89 - 90, Extract the repeated "close drawer then navigate" pattern into a single helper (e.g., closeAndNavigate) and replace each pair of Navigator.of(context).pop(); Get.toNamed(...) calls with a single call to that helper; the helper should accept the BuildContext and the route name (or an enum/Routes value) and internally call Navigator.of(context).pop() then Get.toNamed(route) so handlers across nav_drawer.dart (including the calls around Navigator.of(context).pop(); Get.toNamed(Routes.PROFILE); and the other similar pairs) use the shared function.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@lib/app/modules/home/views/nav_drawer.dart`:
- Around line 89-90: Extract the repeated "close drawer then navigate" pattern
into a single helper (e.g., closeAndNavigate) and replace each pair of
Navigator.of(context).pop(); Get.toNamed(...) calls with a single call to that
helper; the helper should accept the BuildContext and the route name (or an
enum/Routes value) and internally call Navigator.of(context).pop() then
Get.toNamed(route) so handlers across nav_drawer.dart (including the calls
around Navigator.of(context).pop(); Get.toNamed(Routes.PROFILE); and the other
similar pairs) use the shared function.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 1f938a4e-74f5-4d88-89d8-bc7f75b2b851
📒 Files selected for processing (1)
lib/app/modules/home/views/nav_drawer.dart
Description
Fix navigation drawer not closing on selection
Added
Navigator.popto the drawer menu items (Profile, Reports, Settings). Previously, the drawer stayed open in the background when navigating to other screens, which made the UI look glitchy when pressing back.Fixes
Fixes: #628
Screenshots
Before
FILE.2026-03-15.19.03.53.mp4
After
FILE.2026-03-15.19.04.04.mp4
Summary by CodeRabbit
Bug Fixes