fix: use Builder to get descendant context for Scaffold.of() in bottom nav (#403)

## 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 <sharedinbox@thomas-guettler.de>
Reviewed-on: https://codeberg.org/guettli/sharedinbox/pulls/403
This commit was merged in pull request #403.
This commit is contained in:
Bot of Thomas Güttler
2026-06-04 06:16:24 +02:00
committed by guettli
co-authored by guettli Thomas SharedInbox
parent b0354c7423
commit cd8c930000
+6 -4
View File
@@ -51,10 +51,12 @@ class MailboxListScreen extends ConsumerWidget {
? BottomAppBar( ? BottomAppBar(
child: Row( child: Row(
children: [ children: [
IconButton( Builder(
icon: const Icon(Icons.menu), builder: (ctx) => IconButton(
tooltip: 'Open folders', icon: const Icon(Icons.menu),
onPressed: () => Scaffold.of(context).openDrawer(), tooltip: 'Open folders',
onPressed: () => Scaffold.of(ctx).openDrawer(),
),
), ),
], ],
), ),