mirror of
https://github.com/FoggedLens/deflock-app.git
synced 2026-08-14 07:00:28 +02:00
Add mounted guards for BuildContext use across async gaps
This commit is contained in:
@@ -89,7 +89,8 @@ class _AddNodeSheetState extends State<AddNodeSheet> {
|
||||
void _checkSubmissionGuideAndProceed(BuildContext context, AppState appState, LocalizationService locService) async {
|
||||
// Check if user has seen the submission guide
|
||||
final hasSeenGuide = await ChangelogService().hasSeenSubmissionGuide();
|
||||
|
||||
if (!context.mounted) return;
|
||||
|
||||
if (!hasSeenGuide) {
|
||||
// Show submission guide dialog first
|
||||
final shouldProceed = await showDialog<bool>(
|
||||
@@ -97,13 +98,14 @@ class _AddNodeSheetState extends State<AddNodeSheet> {
|
||||
barrierDismissible: false,
|
||||
builder: (context) => const SubmissionGuideDialog(),
|
||||
);
|
||||
|
||||
if (!context.mounted) return;
|
||||
|
||||
// If user canceled the submission guide, don't proceed with submission
|
||||
if (shouldProceed != true) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Now proceed with proximity check
|
||||
_checkProximityOnly(context, appState, locService);
|
||||
}
|
||||
|
||||
@@ -185,6 +185,7 @@ class AdvancedEditOptionsSheet extends StatelessWidget {
|
||||
}
|
||||
|
||||
// No custom scheme or app launch failed - redirect to app store
|
||||
if (!context.mounted) return;
|
||||
await _redirectToAppStore(context, editor);
|
||||
}
|
||||
|
||||
|
||||
@@ -264,8 +264,9 @@ class _DownloadAreaDialogState extends State<DownloadAreaDialog> {
|
||||
try {
|
||||
final id = DateTime.now().toIso8601String().replaceAll(':', '-');
|
||||
final appDocDir = await OfflineAreaService().getOfflineAreaDir();
|
||||
if (!context.mounted) return;
|
||||
final dir = "${appDocDir.path}/$id";
|
||||
|
||||
|
||||
// Get current tile provider info
|
||||
final appState = context.read<AppState>();
|
||||
final selectedProvider = appState.selectedTileProvider;
|
||||
@@ -292,6 +293,7 @@ class _DownloadAreaDialogState extends State<DownloadAreaDialog> {
|
||||
builder: (context) => const DownloadStartedDialog(),
|
||||
);
|
||||
} catch (e) {
|
||||
if (!context.mounted) return;
|
||||
Navigator.pop(context);
|
||||
showDialog(
|
||||
context: context,
|
||||
|
||||
@@ -92,7 +92,8 @@ class _EditNodeSheetState extends State<EditNodeSheet> {
|
||||
void _checkSubmissionGuideAndProceed(BuildContext context, AppState appState, LocalizationService locService) async {
|
||||
// Check if user has seen the submission guide
|
||||
final hasSeenGuide = await ChangelogService().hasSeenSubmissionGuide();
|
||||
|
||||
if (!context.mounted) return;
|
||||
|
||||
if (!hasSeenGuide) {
|
||||
// Show submission guide dialog first
|
||||
final shouldProceed = await showDialog<bool>(
|
||||
@@ -100,13 +101,14 @@ class _EditNodeSheetState extends State<EditNodeSheet> {
|
||||
barrierDismissible: false,
|
||||
builder: (context) => const SubmissionGuideDialog(),
|
||||
);
|
||||
|
||||
if (!context.mounted) return;
|
||||
|
||||
// If user canceled the submission guide, don't proceed with submission
|
||||
if (shouldProceed != true) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Now proceed with proximity check
|
||||
_checkProximityOnly(context, appState, locService);
|
||||
}
|
||||
|
||||
@@ -96,7 +96,8 @@ class NuclearResetDialog extends StatelessWidget {
|
||||
|
||||
// Clear all app data
|
||||
await NuclearResetService.clearEverything();
|
||||
|
||||
|
||||
if (!context.mounted) return;
|
||||
// Show non-dismissible dialog
|
||||
await showDialog(
|
||||
context: context,
|
||||
|
||||
Reference in New Issue
Block a user