showToast method

dynamic showToast(
  1. String msg,
  2. BuildContext _context, {
  3. bool isError = false,
  4. bool isSuccess = true,
})

Shows a toast message

Implementation

showToast(String msg, BuildContext _context,
    {bool isError = false, bool isSuccess = true}) {
  try {
    ScaffoldMessenger.of(_context).showSnackBar(SnackBar(
      content: Text(msg),
      backgroundColor: isError ? AllColors().RED : AllColors().GREEN,
      dismissDirection: DismissDirection.horizontal,
    ));
  } catch (e) {
    CustomToast().show(msg, navKey.currentContext!,
        isError: isError, isSuccess: isSuccess);
  }
}