@@ -7,6 +7,7 @@ import '../../../providers/notes/notes_provider.dart';
77import '../../../providers/notifiers/notifiers.dart' ;
88import '../../constants/constants.dart' ;
99import '../../dialogs/confirmation_dialog.dart' ;
10+ import '../../extensions/build_context_extension.dart' ;
1011import '../../ui/snack_bar_utils.dart' ;
1112import 'archive.dart' ;
1213import 'restore.dart' ;
@@ -22,7 +23,12 @@ Future<bool> deleteNote(
2223 bool pop = false ,
2324 bool cancel = true ,
2425}) async {
25- if (! await askForConfirmation (context, l.dialog_delete, l.dialog_delete_body (1 ), l.dialog_delete)) {
26+ if (! await askForConfirmation (
27+ context,
28+ context.l.dialog_delete,
29+ context.l.dialog_delete_body (1 ),
30+ context.l.dialog_delete,
31+ )) {
2632 return false ;
2733 }
2834
@@ -39,9 +45,10 @@ Future<bool> deleteNote(
3945 .read (notesProvider (status: NoteStatus .available, label: currentLabelFilter).notifier)
4046 .setDeleted ([note], true );
4147
42- if (succeeded && cancel) {
48+ if (succeeded && cancel && context.mounted ) {
4349 SnackBarUtils ().show (
44- text: l.snack_bar_deleted (1 ),
50+ context,
51+ text: context.l.snack_bar_deleted (1 ),
4552 onCancel:
4653 (globalRef) async =>
4754 wasArchived
@@ -57,7 +64,12 @@ Future<bool> deleteNote(
5764///
5865/// Returns `true` if the [notes] were deleted, `false` otherwise.
5966Future <bool > deleteNotes (BuildContext context, WidgetRef ref, {required List <Note > notes, bool cancel = true }) async {
60- if (! await askForConfirmation (context, l.dialog_delete, l.dialog_delete_body (notes.length), l.dialog_delete)) {
67+ if (! await askForConfirmation (
68+ context,
69+ context.l.dialog_delete,
70+ context.l.dialog_delete_body (notes.length),
71+ context.l.dialog_delete,
72+ )) {
6173 return false ;
6274 }
6375
@@ -71,9 +83,10 @@ Future<bool> deleteNotes(BuildContext context, WidgetRef ref, {required List<Not
7183 exitNotesSelectionMode (context, ref, notesStatus: NoteStatus .available);
7284 }
7385
74- if (succeeded && cancel) {
86+ if (succeeded && cancel && context.mounted ) {
7587 SnackBarUtils ().show (
76- text: l.snack_bar_deleted (notes.length),
88+ context,
89+ text: context.l.snack_bar_deleted (notes.length),
7790 onCancel:
7891 (globalRef) async =>
7992 wereArchived
@@ -91,9 +104,9 @@ Future<bool> deleteNotes(BuildContext context, WidgetRef ref, {required List<Not
91104Future <bool > permanentlyDeleteNote (BuildContext context, WidgetRef ref, {required Note note, bool pop = false }) async {
92105 if (! await askForConfirmation (
93106 context,
94- l.dialog_permanently_delete,
95- l.dialog_permanently_delete_body (1 ),
96- l.dialog_permanently_delete,
107+ context. l.dialog_permanently_delete,
108+ context. l.dialog_permanently_delete_body (1 ),
109+ context. l.dialog_permanently_delete,
97110 irreversible: true ,
98111 )) {
99112 return false ;
@@ -121,9 +134,9 @@ Future<bool> permanentlyDeleteNote(BuildContext context, WidgetRef ref, {require
121134Future <bool > permanentlyDeleteNotes (BuildContext context, WidgetRef ref, {required List <Note > notes}) async {
122135 if (! await askForConfirmation (
123136 context,
124- l.dialog_permanently_delete,
125- l.dialog_permanently_delete_body (notes.length),
126- l.dialog_permanently_delete,
137+ context. l.dialog_permanently_delete,
138+ context. l.dialog_permanently_delete_body (notes.length),
139+ context. l.dialog_permanently_delete,
127140 irreversible: true ,
128141 )) {
129142 return false ;
@@ -142,9 +155,9 @@ Future<bool> permanentlyDeleteNotes(BuildContext context, WidgetRef ref, {requir
142155Future <bool > emptyBin (BuildContext context, WidgetRef ref) async {
143156 if (! await askForConfirmation (
144157 context,
145- l.dialog_empty_bin,
146- l.dialog_empty_bin_body,
147- l.dialog_empty_bin,
158+ context. l.dialog_empty_bin,
159+ context. l.dialog_empty_bin_body,
160+ context. l.dialog_empty_bin,
148161 irreversible: true ,
149162 )) {
150163 return false ;
0 commit comments