Skip to content

Settings Page back navigation error and snackbar show error fix #581

Merged
SGI-CAPP-AT2 merged 2 commits intoCCExtractor:mainfrom
rohansen856:settings_navigation_fix
Feb 4, 2026
Merged

Settings Page back navigation error and snackbar show error fix #581
SGI-CAPP-AT2 merged 2 commits intoCCExtractor:mainfrom
rohansen856:settings_navigation_fix

Conversation

@rohansen856
Copy link
Contributor

@rohansen856 rohansen856 commented Feb 3, 2026

Description

Fix for Navigation Issue

Replaced Get.back() with a safer navigation approach in lib/app/modules/settings/views/settings_page_app_bar.dart

// Before
leading: GestureDetector(
  onTap: () {
    Get.back();
  },
  // ...
),

// After
leading: GestureDetector(
  onTap: () {
    if (Get.isSnackbarOpen == true) {
      Get.closeCurrentSnackbar();
    }
    Navigator.of(context).pop();
  },
  // ...
),

This now:

  • Checks if a snackbar is open before attempting to close it
  • Uses Flutter's standard Navigator.pop() which doesn't automatically try to close snackbars
  • Prevents the LateInitializationError by avoiding GetX's automatic snackbar closing logic

Fix for Snackbar Issue

Capture the ScaffoldMessengerState before the async operation to safely show the snackbar later in lib/app/modules/settings/controllers/settings_controller.dart:

// Before
void pickDirectory(BuildContext context) {
  TaskwarriorColorTheme tColors = Theme.of(context).extension<TaskwarriorColorTheme>()!;
  FilePicker.platform.getDirectoryPath().then((value) async {
    // ... async operations ...
    } else if (value == "success") {
      profilesWidget.setBaseDirectory(destination);
      SharedPreferences prefs = await SharedPreferences.getInstance();
      prefs.setString('baseDirectory', destination.path);
      baseDirectory.value = destination.path;
      Get.snackbar(
        'Success',
        'Base directory moved successfully',
        snackPosition: SnackPosition.BOTTOM,
        duration: const Duration(seconds: 2),
      );
    }
  });
}

// After
void pickDirectory(BuildContext context) {
  TaskwarriorColorTheme tColors = Theme.of(context).extension<TaskwarriorColorTheme>()!;
  // Capture ScaffoldMessenger before async operation
  final scaffoldMessenger = ScaffoldMessenger.of(context);
  FilePicker.platform.getDirectoryPath().then((value) async {
    // ... async operations ...
    } else if (value == "success") {
      profilesWidget.setBaseDirectory(destination);
      SharedPreferences prefs = await SharedPreferences.getInstance();
      prefs.setString('baseDirectory', destination.path);
      baseDirectory.value = destination.path;
      // Show success snackbar using captured ScaffoldMessenger
      scaffoldMessenger.showSnackBar(
        SnackBar(
          content: Text(
            'Base directory moved successfully',
            style: TextStyle(color: tColors.primaryTextColor),
          ),
          backgroundColor: tColors.secondaryBackgroundColor,
          duration: const Duration(seconds: 2),
        ),
      );
    }
  });
}

this now:

  • Captures the ScaffoldMessengerState early, before any async operations that might invalidate the context
  • the captured messenger reference remains valid even after context is deactivated
  • uses Flutter's standard snackbar mechanism

Fixes #580

Screenshots

WhatsApp.Video.2026-02-03.at.2.30.34.PM.mp4

Checklist

  • Tests have been added or updated to cover the changes
  • Documentation has been updated to reflect the changes
  • Code follows the established coding style guidelines
  • All tests are passing

Signed-off-by: rohansen856 <rohansen856@gmail.com>
Signed-off-by: rohansen856 <rohansen856@gmail.com>
@SGI-CAPP-AT2 SGI-CAPP-AT2 merged commit 1ea088c into CCExtractor:main Feb 4, 2026
2 checks passed
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.

Bug: Navigation and snackbar error in settings page

2 participants