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:
2026-03-01 13:39:06 -05:00
parent d01978ab46
commit 6e996d9d2e
+5 -3
View File
@@ -54,15 +54,17 @@ class NoteDetailScreen extends ConsumerWidget {
onPressed: () async { onPressed: () async {
final confirm = await showDialog<bool>( final confirm = await showDialog<bool>(
context: context, context: context,
builder: (_) => AlertDialog( builder: (dialogContext) => AlertDialog(
title: const Text('Delete note?'), title: const Text('Delete note?'),
actions: [ actions: [
TextButton( TextButton(
onPressed: () => Navigator.pop(context, false), onPressed: () =>
Navigator.pop(dialogContext, false),
child: const Text('Cancel'), child: const Text('Cancel'),
), ),
TextButton( TextButton(
onPressed: () => Navigator.pop(context, true), onPressed: () =>
Navigator.pop(dialogContext, true),
child: const Text('Delete'), child: const Text('Delete'),
), ),
], ],