toast.dart 592 B

12345678910111213141516171819202122232425262728
  1. import 'package:flutter/material.dart';
  2. import 'package:fluttertoast/fluttertoast.dart' as t;
  3. class Toast {
  4. final t.FToast _fToast = t.FToast();
  5. late BuildContext buildContext;
  6. void initialize(BuildContext context) {
  7. _fToast.init(context);
  8. }
  9. void show(String text) {
  10. t.Fluttertoast.showToast(
  11. msg: text,
  12. toastLength: t.Toast.LENGTH_LONG,
  13. gravity: t.ToastGravity.CENTER,
  14. );
  15. }
  16. void showBottom(String text) {
  17. t.Fluttertoast.showToast(
  18. msg: text,
  19. toastLength: t.Toast.LENGTH_LONG,
  20. gravity: t.ToastGravity.BOTTOM,
  21. );
  22. }
  23. }