YurToast function

void YurToast({
  1. required String message,
  2. InfoType toastType = InfoType.info,
  3. Toast duration = Toast.LENGTH_SHORT,
  4. ToastGravity gravity = ToastGravity.CENTER,
  5. int timeInSecForIosWeb = 1,
  6. Color? backgroundColor,
  7. Color? textColor = Colors.white,
  8. double fontSize = 14.0,
})

Implementation

void YurToast({
  required String message,
  InfoType toastType = InfoType.info,
  Toast duration = Toast.LENGTH_SHORT,
  ToastGravity gravity = ToastGravity.CENTER,
  int timeInSecForIosWeb = 1,
  Color? backgroundColor,
  Color? textColor = Colors.white,
  double fontSize = 14.0,
}) {
  if (backgroundColor == null) {
    switch (toastType) {
      case InfoType.info:
        backgroundColor = primaryRed;
        break;
      case InfoType.warning:
        backgroundColor = secondaryYellow;
        break;
      case InfoType.error:
        backgroundColor = primaryRed;
        break;
      case InfoType.success:
        backgroundColor = tertiaryGreen;
        break;
    }
  }

  YurLog(name: "YurToast", message);

  Fluttertoast.showToast(
    msg: message,
    toastLength: duration,
    gravity: gravity,
    timeInSecForIosWeb: timeInSecForIosWeb,
    backgroundColor: backgroundColor,
    textColor: textColor,
    fontSize: fontSize,
  );
}