You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
1.8KB

  1. import 'package:flutter/material.dart';
  2. import 'package:get/get.dart';
  3. class Utils {
  4. static void showSnackBarSuccess({String message}) {
  5. if (Get.isSnackbarOpen) Get.back();
  6. Get.snackbar(null, message,
  7. icon: Icon(
  8. Icons.done,
  9. color: Colors.white,
  10. ),
  11. snackPosition: SnackPosition.BOTTOM,
  12. backgroundColor: Colors.green);
  13. }
  14. static void showSnackBarError({String message}) {
  15. if (Get.isSnackbarOpen) Get.back();
  16. Get.snackbar(null, message,
  17. icon: Icon(
  18. Icons.error,
  19. color: Colors.white,
  20. ),
  21. snackPosition: SnackPosition.BOTTOM,
  22. backgroundColor: Colors.red);
  23. }
  24. static void showSnackBarWarning({String message}) {
  25. if (Get.isSnackbarOpen) Get.back();
  26. Get.snackbar(null, message,
  27. icon: Icon(
  28. Icons.warning,
  29. color: Colors.yellow,
  30. ),
  31. snackPosition: SnackPosition.BOTTOM,
  32. backgroundColor: Colors.yellow[50]);
  33. }
  34. static void showDialog(
  35. {@required String title,
  36. @required String message,
  37. @required String textConfirm,
  38. @required String textCancel,
  39. @required Function() onConfirm}) {
  40. if (Get.isDialogOpen) Get.back();
  41. Get.defaultDialog(
  42. title: title,
  43. middleText: message,
  44. textConfirm: textConfirm,
  45. textCancel: textCancel,
  46. confirmTextColor: Colors.white,
  47. onConfirm: onConfirm,
  48. onCancel: () {
  49. Get.back();
  50. },
  51. );
  52. }
  53. static void showDialogConfirmSupply({@required Function() onConfirm}) {
  54. if (Get.isDialogOpen) Get.back();
  55. Get.defaultDialog(
  56. title: "Vật tư chưa được thêm",
  57. middleText: "Bạn có muốn cập nhật?",
  58. textConfirm: "Tiếp tục",
  59. textCancel: "Xem lại",
  60. confirmTextColor: Colors.white,
  61. onConfirm: onConfirm);
  62. }
  63. }