toast_util.dart 726 B

1234567891011121314151617181920212223242526
  1. import 'package:flutter/cupertino.dart';
  2. import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
  3. class ToastUtil {
  4. ToastUtil._();
  5. static int lengthShort = 2000;
  6. static int lengthLong = 3500;
  7. static void show(String? msg,
  8. {Duration? displayTime,
  9. SmartToastType? displayType = SmartToastType.normal,
  10. bool? addPostFrame}) {
  11. if (msg != null) {
  12. if (addPostFrame == true) {
  13. WidgetsBinding.instance.addPostFrameCallback((_) {
  14. SmartDialog.showToast(msg,
  15. displayType: displayType, displayTime: displayTime);
  16. });
  17. } else {
  18. SmartDialog.showToast(msg,
  19. displayType: displayType, displayTime: displayTime);
  20. }
  21. }
  22. }
  23. }