Skip to content

fix: resolve import backup silently failing due to deactivated widget context#112

Open
ivanwongtf wants to merge 160 commits into
LeanBitLab:mainfrom
ivanwongtf:fix/import-deactivated-context
Open

fix: resolve import backup silently failing due to deactivated widget context#112
ivanwongtf wants to merge 160 commits into
LeanBitLab:mainfrom
ivanwongtf:fix/import-deactivated-context

Conversation

@ivanwongtf

Copy link
Copy Markdown

Summary

Fixes #111

Import Backup in settings silently fails because the confirmation dialog's pop deactivates the parent widget context before _import() can access service providers.

Problem

In _confirmFileImport(), after the user clicks Import:

  1. Navigator.of(dialogContext).pop() closes the confirmation dialog
  2. _import(context, ...) is called with the now-deactivated parent context
  3. context.read<BackupService>() throws "Looking up a deactivated widget's ancestor is unsafe"
  4. Since _import() is called without await, the error becomes an unhandled async exception and is silently swallowed

Fix

Read service providers before showing the dialog while the context is still valid:

Future<void> _confirmFileImport(
    BuildContext context, AppLocalizations localizations, BackupFileEntry entry) async {
  // Read services BEFORE showing dialog while context is still valid
  final backupService = context.read<BackupService>();
  final settingsService = context.read<SettingsService>();
  final appsService = context.read<AppsService>();
  
  showDialog(
    context: context,
    builder: (dialogContext) => AlertDialog(
      // ... dialog with Import button that calls:
      // backupService.importBackup(entry.file)
      // instead of relying on deactivated context
    ),
  );
}

Changes

  • lib/widgets/settings/backup_restore_page.dart: Read services before dialog, call importBackup() directly
  • Removed the _import() helper method that was the source of the deactivated context bug

Testing

Verified on Samsung SM-F946U (Android 16) with 188 apps across 13 categories - import now works correctly.

LeanBitLab and others added 30 commits May 17, 2026 05:47
…h-10803040634688039088

🧹 refactor: remove unused `_swatch` variable in `flauncher_app.dart`
Adds `test/models/category_test.dart` to verify the constructors and fields of the `Category` model, as well as the `unmodifiable()` method. Also adds a basic test for `LauncherSpacer`. This resolves the issue of missing tests for the Category model.
…6392016201667835771

🧪 Add unit tests for Category model
…toggle-16740655243048156961

🧪 Add tests for LauncherState.toggleLauncherVisibility
Removed dead code in `test/widgets/app_card_test.dart` including an unused import, and unused local variables (`movedDirection`, `state`, and `moveEnded`). This resolves linting warnings and improves the test's clarity.
…used-variables-5594749462216507943

🧹 fix unused local variables in app_card_test.dart
…uilds

- New Accessibility settings page with default launcher status
  and 'Set as default launcher' button (opens system home picker)
- Android: added openDefaultLauncherSettings method channel handler
- Dart: added openDefaultLauncherSettings to FLauncherChannel
- L10n: added English and Spanish translations
- Gitignore: drift_schemas/, test/generated_migrations/,
  test/mocks.mocks.dart, .vscode/

Co-authored-by: pre-existing refactoring (database migration
safety, test renames, widget improvements)
…tion safety, and accessibility docs"

This reverts commit 497d707.
- Add TV Input selector status bar button next to settings

- Configure ndk.abiFilters to package only ARM architectures

- Fix category order jumbling and SD card reboot app-loss
LeanBitLab and others added 29 commits July 10, 2026 00:43
… 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.
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.

3 participants