toast_util.dart 942 B

12345678910111213141516171819202122232425262728293031323334
  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. Alignment? alignment,
  10. SmartToastType? displayType = SmartToastType.normal,
  11. WidgetBuilder? builder,
  12. bool? addPostFrame}) {
  13. if (msg != null) {
  14. if (addPostFrame == true) {
  15. WidgetsBinding.instance.addPostFrameCallback((_) {
  16. SmartDialog.showToast(msg,
  17. builder: builder,
  18. alignment: alignment,
  19. displayType: displayType,
  20. displayTime: displayTime);
  21. });
  22. } else {
  23. SmartDialog.showToast(msg,
  24. builder: builder,
  25. alignment: alignment,
  26. displayType: displayType,
  27. displayTime: displayTime);
  28. }
  29. }
  30. }
  31. }