Fix black screen and failed delete when confirming note deletion
The dialog builder was discarding its own context (_) and calling Navigator.pop(context, ...) with the outer screen context instead. This popped NoteDetailScreen off the navigator instead of closing the dialog, causing a black screen and returning null to showDialog so the delete operation never ran. Fix: use dialogContext in the builder and pop that instead. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -54,15 +54,17 @@ class NoteDetailScreen extends ConsumerWidget {
|
||||
onPressed: () async {
|
||||
final confirm = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (_) => AlertDialog(
|
||||
builder: (dialogContext) => AlertDialog(
|
||||
title: const Text('Delete note?'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context, false),
|
||||
onPressed: () =>
|
||||
Navigator.pop(dialogContext, false),
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context, true),
|
||||
onPressed: () =>
|
||||
Navigator.pop(dialogContext, true),
|
||||
child: const Text('Delete'),
|
||||
),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user