fix: resolve import backup silently failing due to deactivated widget context#113
Open
ivanwongtf wants to merge 1 commit into
Open
fix: resolve import backup silently failing due to deactivated widget context#113ivanwongtf wants to merge 1 commit into
ivanwongtf wants to merge 1 commit into
Conversation
… context The _import() function was called with a context that becomes deactivated when the confirmation dialog is popped, causing context.read<BackupService>() to throw an unsafe ancestor lookup error. The error was silently swallowed because _import() was not awaited. Fix: read service providers before showing the dialog while the context is still valid, then call importBackup directly without relying on the widget context.
This was referenced Jul 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #111
Problem
In
_confirmFileImport(), after the user clicks Import:Navigator.of(dialogContext).pop()closes the confirmation dialog_import(context, ...)is called with the now-deactivated parent contextcontext.read<BackupService>()throws"Looking up a deactivated widget's ancestor is unsafe"_import()was not awaited, the error was silently swallowedFix
Read service providers before showing the dialog while the context is still valid, then call
importBackup()directly without relying on the widget context.Changes
lib/widgets/settings/backup_restore_page.dart: read services before dialog, callimportBackup()directly, remove the_import()helperTesting
Verified on Samsung SM-F946U (Android 16) with 188 apps across 13 categories — import now works correctly.