Skip to content

Replace inner Navigator with Overlay (fixes #31, #35) — v5.0.0#38

Draft
tomalabaster wants to merge 1 commit into
developfrom
cursor/overlay-instead-of-navigator-3a7a
Draft

Replace inner Navigator with Overlay (fixes #31, #35) — v5.0.0#38
tomalabaster wants to merge 1 commit into
developfrom
cursor/overlay-instead-of-navigator-3a7a

Conversation

@tomalabaster
Copy link
Copy Markdown
Owner

Summary

Revives the overlay-based approach from feature/#31_-_use_overlay_instead_of_navigator, rebased onto current develop (4.3.0), as a 5.0.0 release.

AppLock no longer wraps the app in a nested Navigator. Lock and inactive screens are layered via OverlayEntry instead, leaving MaterialApp's navigator as the sole route stack.

Fixes

Architecture

MaterialApp
└── AppLock
    └── Overlay
        ├── Entry: app (MaterialApp Navigator — sole route stack)
        ├── Entry: lock screen (when locked)
        └── Entry: inactive screen (when inactive)

Notable implementation details

  • Imperative overlay sync — single _syncOverlays() path; avoids mixing initialEntries with manual insert/remove (root cause of iOS background-lock bugs on the old WIP branch)
  • Deferred background lock — if the latency timer fires while the app is still backgrounded, lock is shown on next resumed (addresses iOS reports on After implementing AppLock, the device back button closes the app instead of returning to the previous screen (Android) #35)
  • Offstage app content — when lock or inactive overlay is visible, app content stays mounted (maintainState) but is offstage, matching prior navigator semantics for tests and state preservation
  • Breaking API cleanup — removed deprecated lockScreen, enabled, and backgroundLockLatency constructor parameters (slated for 5.0.0)

Test plan

  • All 88 existing widget tests pass
  • 6 new overlay/regression tests (test/src/app_lock_overlay_test.dart):
    • Overlay entry mount state
    • Deferred background lock on resume
    • InactiveBehavior.alwaysShow when disabled
    • Hero navigation through AppLock
    • Android back after dialog dismiss
  • flutter analyze clean
  • Manual verification on Android (dialog + back, Hero)
  • Manual verification on iOS (background lock with latency)

Example app adds Hero test and Dialog then back test buttons for manual QA.

Migration (4.x → 5.0)

No integration pattern change — still use MaterialApp.builder. Replace any remaining deprecated constructor args:

Removed (4.x) Use instead
lockScreen lockScreenBuilder
enabled initiallyEnabled
backgroundLockLatency initialBackgroundLockLatency

Closes #31, #35

Open in Web Open in Cursor 

AppLock now layers lock and inactive screens via OverlayEntry instead
of a nested Navigator, fixing Hero animations (#31) and Android back
navigation after dialogs (#35).

- Imperative overlay sync with first-frame initialEntries
- Defer background lock until app resumes when timer fires off-screen
- Offstage app content when lock or inactive overlay is visible
- Remove deprecated lockScreen, enabled, and backgroundLockLatency APIs
- Add overlay and navigation regression tests
- Extend example app with Hero and dialog/back demos

Co-authored-by: Tom Alabaster <tomalabasteruk@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants