Skip to content

Import Backup silently fails due to deactivated widget context #111

Description

@ivanwongtf

Bug Description

Import Backup in settings does nothing when clicking the Import button in the confirmation dialog. No success/error dialog appears, and no changes are applied. This affects all versions tested (v2026.04.26 through v2026.07.12).

Steps to Reproduce

  1. Export a backup from LTvLauncher settings
  2. Click Import Backup
  3. Select a backup file from the list
  4. Click Import in the confirmation dialog
  5. The dialog closes but nothing happens - no success/error message, no categories changed

Root Cause

In backup_restore_page.dart, the _confirmFileImport method calls _import(context, ...) after popping the confirmation dialog with Navigator.of(dialogContext).pop(). However, popping the dialog deactivates the parent widget context, so when _import() calls context.read<BackupService>(), Flutter throws:

Looking up a deactivated widget's ancestor is unsafe.

Since _import() is called without await, this becomes an unhandled async exception that is silently swallowed - no error dialog is shown.

Debug Evidence

Added logging and confirmed:

[LTV_DEBUG] _confirmFileImport called for backup.json
[LTV_DEBUG] Import button pressed
[LTV_DEBUG] _import called, mounted=false
[LTV_DEBUG] _import FAILED: Looking up a deactivated widget's ancestor is unsafe.
[LTV_DEBUG] context.mounted=false

Suggested Fix

Read service providers (BackupService, SettingsService, AppsService) before showing the confirmation dialog while the context is still valid, then call importBackup() directly without relying on the widget context.

See PR: #112

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions