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

Merged
guettlibot merged 1 commits from refs/pull/403/head into main 2026-06-04 04:16:25 +00:00
guettlibot commented 2026-06-04 02:06:32 +00:00 (Migrated from codeberg.org)

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

## 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)
Sign in to join this conversation.