From cd8c93000099ec59d05dce0ac5618e4776dc34a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bot=20of=20Thomas=20G=C3=BCttler?= Date: Thu, 4 Jun 2026 06:16:24 +0200 Subject: [PATCH] fix: use Builder to get descendant context for Scaffold.of() in bottom nav (#403) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary Fixes the crash reported in #397: `Scaffold.of() called with a context that does not contain a Scaffold.` - `Scaffold.of(context)` was called in the `onPressed` of the bottom-nav menu `IconButton` using the widget's own `build` context. That context is the *parent* of the `Scaffold` being returned, so Flutter correctly throws. - Fix: wrap the `IconButton` in a `Builder`, which provides a child `ctx` that is a proper descendant of the `Scaffold`. `Scaffold.of(ctx)` then resolves correctly. ## Test plan - [ ] Run app with bottom menu position enabled, tap the hamburger icon — drawer opens without crashing. - [ ] Run app with top menu position — no regression (bottom nav is not rendered). Closes #397 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Thomas SharedInbox Reviewed-on: https://codeberg.org/guettli/sharedinbox/pulls/403 --- lib/ui/screens/mailbox_list_screen.dart | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/ui/screens/mailbox_list_screen.dart b/lib/ui/screens/mailbox_list_screen.dart index 47fc231..672cda6 100644 --- a/lib/ui/screens/mailbox_list_screen.dart +++ b/lib/ui/screens/mailbox_list_screen.dart @@ -51,10 +51,12 @@ class MailboxListScreen extends ConsumerWidget { ? BottomAppBar( child: Row( children: [ - IconButton( - icon: const Icon(Icons.menu), - tooltip: 'Open folders', - onPressed: () => Scaffold.of(context).openDrawer(), + Builder( + builder: (ctx) => IconButton( + icon: const Icon(Icons.menu), + tooltip: 'Open folders', + onPressed: () => Scaffold.of(ctx).openDrawer(), + ), ), ], ),