Skip to content

Bug: context.mounted crash in settings_drawer.dart after sign-out #5652

@beastoin

Description

@beastoin

Tapping Sign Out in the settings drawer crashes the app because the widget tree navigates to the auth screen while the drawer is still mounted. The sign-out handler calls AuthService.instance.signOut() which triggers auth state changes that tear down the widget tree, but the drawer's callback continues executing and hits context.mounted on a disposed context. This blocks automated E2E testing of the logout→login flow — agents must force-stop and relaunch after every sign-out (~30s overhead per test run).

Current Behavior

  • User taps Sign Out → confirms with Ok
  • Navigator.of(ctx).pop() dismisses the confirmation dialog but NOT the drawer
  • AuthService.instance.signOut() fires, auth state listener navigates to auth screen
  • Drawer widget is disposed mid-callback, context.mounted check fails or crashes

Expected Behavior

Sign-out should dismiss the drawer first, then clear auth state and navigate cleanly to the auth screen without crash or freeze.

Affected Areas

File Line Description
app/lib/pages/settings/settings_drawer.dart 564-570 First sign-out handler: pops dialog but not drawer before signOut
app/lib/pages/settings/settings_drawer.dart 629-635 Second sign-out handler: same pattern

Solution

Dismiss the drawer (e.g., Navigator.of(context).pop()) before calling AuthService.instance.signOut(), or wrap the post-signOut navigation in a mounted guard that accounts for the drawer being disposed.

Files to Modify

  • app/lib/pages/settings/settings_drawer.dart

Impact

Low risk — only affects the sign-out flow. No impact on recording, transcription, or data paths.


by AI for @beastoin

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingflutterflutter workp3Priority: Backlog (score <14)ux-polishLayer: UI layout, animations, wording

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions