|
- import 'package:flutter/material.dart';
- import 'package:get/get.dart';
-
- class Utils {
- static void showSnackBarSuccess({String? message}) {
- if (Get.isSnackbarOpen) Get.back();
- Get.snackbar('Thành công', message ?? '',
- icon: Icon(
- Icons.done,
- color: Colors.white,
- ),
- snackPosition: SnackPosition.BOTTOM,
- backgroundColor: Colors.green);
- }
-
- static void showSnackBarError({String? message}) {
- if (Get.isSnackbarOpen) Get.back();
- Get.snackbar('Lỗi', message ?? '',
- icon: Icon(
- Icons.error,
- color: Colors.white,
- ),
- snackPosition: SnackPosition.BOTTOM,
- backgroundColor: Colors.red);
- }
-
- static void showSnackBarWarning({String? message}) {
- if (Get.isSnackbarOpen) Get.back();
- Get.snackbar('Cảnh báo', message ?? '',
- icon: Icon(
- Icons.warning,
- color: Colors.yellow,
- ),
- snackPosition: SnackPosition.BOTTOM,
- backgroundColor: Colors.yellow[50]);
- }
-
- static void showDialog(
- {required String title, required String message, required String textConfirm, required String textCancel, required Function() onConfirm}) {
- if (Get.isDialogOpen ?? false) Get.back();
- Get.defaultDialog(
- title: title,
- middleText: message,
- textConfirm: textConfirm,
- textCancel: textCancel,
- confirmTextColor: Colors.white,
- onConfirm: onConfirm,
- );
- }
-
- static void showDialogConfirmSupply({required Function() onConfirm}) {
- if (Get.isDialogOpen ?? false) Get.back();
- Get.defaultDialog(
- title: "Vật tư chưa được thêm",
- middleText: "Bạn có muốn cập nhật?",
- textConfirm: "Tiếp tục",
- textCancel: "Xem lại",
- confirmTextColor: Colors.white,
- onConfirm: onConfirm);
- }
- }
|