Skip to content

Commit 28280b5

Browse files
committed
'dismiss' can close dialogs with duplicate tags
1 parent e0523f5 commit 28280b5

File tree

3 files changed

+4
-8
lines changed

3 files changed

+4
-8
lines changed

lib/src/custom/custom_dialog.dart

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ class CustomDialog extends BaseDialog {
165165

166166
if (keepSingle) {
167167
DialogInfo dialogInfo;
168-
if (proxy.dialogMap[SmartTag.keepSingle] == null) {
168+
if (_getDialog(DialogType.dialog, false, SmartTag.keepSingle) == null) {
169169
dialogInfo = DialogInfo(
170170
dialog: this,
171171
backDismiss: backDismiss,
@@ -174,7 +174,6 @@ class CustomDialog extends BaseDialog {
174174
useSystem: useSystem,
175175
);
176176
proxy.dialogQueue.add(dialogInfo);
177-
proxy.dialogMap[SmartTag.keepSingle] = dialogInfo;
178177
Overlay.of(DialogProxy.contextOverlay)!.insert(
179178
overlayEntry,
180179
below: proxy.entryLoading,
@@ -195,7 +194,6 @@ class CustomDialog extends BaseDialog {
195194
useSystem: useSystem,
196195
);
197196
proxy.dialogQueue.add(dialogInfo);
198-
if (tag != null) proxy.dialogMap[tag] = dialogInfo;
199197
// insert the dialog carrier into the page
200198
Overlay.of(DialogProxy.contextOverlay)!.insert(
201199
overlayEntry,
@@ -262,7 +260,6 @@ class CustomDialog extends BaseDialog {
262260

263261
//handle close dialog
264262
var proxy = DialogProxy.instance;
265-
if (info.tag != null) proxy.dialogMap.remove(info.tag);
266263
proxy.dialogQueue.remove(info);
267264
var customDialog = info.dialog;
268265
await customDialog.mainDialog.dismiss(useSystem: info.useSystem);
@@ -287,7 +284,8 @@ class CustomDialog extends BaseDialog {
287284
if (tag != null && item.tag == tag) {
288285
info = item;
289286
break;
290-
}else if (type == DialogType.dialog || item.type == type) {
287+
} else if (tag == null &&
288+
(type == DialogType.dialog || item.type == type)) {
291289
info = item;
292290
break;
293291
}

lib/src/custom/custom_toast.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class CustomToast extends BaseDialog {
1212
required OverlayEntry overlayEntry,
1313
}) : super(config: config, overlayEntry: overlayEntry);
1414

15-
Queue<Future<void> Function()> _toastQueue = DoubleLinkedQueue();
15+
Queue<Future<void> Function()> _toastQueue = ListQueue();
1616

1717
DateTime? _lastTime;
1818

lib/src/helper/dialog_proxy.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ class DialogProxy {
1616
late Config config;
1717
late OverlayEntry entryToast;
1818
late OverlayEntry entryLoading;
19-
late Map<String, DialogInfo> dialogMap;
2019
late Queue<DialogInfo> dialogQueue;
2120
late CustomToast _toast;
2221
late CustomLoading _loading;
@@ -41,7 +40,6 @@ class DialogProxy {
4140
DialogProxy._internal() {
4241
config = Config();
4342

44-
dialogMap = {};
4543
dialogQueue = ListQueue();
4644
}
4745

0 commit comments

Comments
 (0)