Skip to content

Commit

Permalink
process #235
Browse files Browse the repository at this point in the history
  • Loading branch information
xdd666t committed Nov 9, 2024
1 parent 7aae85e commit 231ab68
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
45 changes: 45 additions & 0 deletions example/lib/demo/issue235_toast.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';

void main() {
runApp(MaterialApp(
navigatorObservers: [FlutterSmartDialog.observer],
builder: FlutterSmartDialog.init(),
home: const MyApp(),
));
}

class MyApp extends StatelessWidget {
const MyApp({super.key});

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text(
"Test",
),
),
body: Center(
child: ElevatedButton(
onPressed: () async {
show("toast1");
show("toast2");
},
child: const Text(
"Click",
),
),
),
);
}

Future show(String msg) {
return SmartDialog.showToast(
msg,
alignment: Alignment.center,
displayType: SmartToastType.last,
displayTime: const Duration(seconds: 3),
);
}
}
4 changes: 3 additions & 1 deletion lib/src/custom/toast/custom_toast.dart
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@ class CustomToast extends BaseDialog {
var toastQueue = ToastTool.instance.toastQueue;
if (toastQueue.isNotEmpty) {
for (var item in toastQueue) {
item.mainDialog.overlayEntry.remove();
await ViewUtils.awaitPostFrame(onPostFrame: () {
item.mainDialog.overlayEntry.remove();
});
}
toastQueue.clear();
ToastTool.instance.cancelLastDelay();
Expand Down

0 comments on commit 231ab68

Please sign in to comment.