Component.dart 647 B

12345678910111213141516171819202122232425262728
  1. import 'package:flutter/material.dart';
  2. import 'package:fluttertoast/fluttertoast.dart';
  3. class Component {
  4. static toast(String msg, int errLevel) {
  5. var bgColor = Colors.blue;
  6. switch(errLevel) {
  7. case 0:
  8. bgColor = Colors.red;
  9. break;
  10. case 1:
  11. bgColor = Colors.yellow;
  12. break;
  13. case 2:
  14. bgColor = Colors.blue;
  15. break;
  16. };
  17. Fluttertoast.showToast(
  18. msg: msg,
  19. toastLength: Toast.LENGTH_SHORT,
  20. gravity: ToastGravity.CENTER,
  21. timeInSecForIosWeb: 1,
  22. backgroundColor: bgColor,
  23. textColor: Colors.white,
  24. fontSize: 16.0);
  25. }
  26. }