toasty function

void toasty(
  1. BuildContext context,
  2. String? text, {
  3. ToastGravity? gravity,
  4. dynamic length = Toast.LENGTH_SHORT,
  5. Color? bgColor,
  6. Color? textColor,
  7. bool print = false,
  8. bool removeQueue = false,
  9. Duration duration = const Duration(seconds: 2),
  10. BorderRadius? borderRadius,
  11. EdgeInsets? padding,
})

Toast with Context

Implementation

void toasty(
  BuildContext context,
  String? text, {
  ToastGravity? gravity,
  length = Toast.LENGTH_SHORT,
  Color? bgColor,
  Color? textColor,
  bool print = false,
  bool removeQueue = false,
  Duration duration = const Duration(seconds: 2),
  BorderRadius? borderRadius,
  EdgeInsets? padding,
}) {
  FToast().init(context);
  if (removeQueue) FToast().removeCustomToast();

  FToast().showToast(
    child: Container(
      child: Text(text.validate(),
          style: boldTextStyle(color: textColor ?? defaultToastTextColor)),
      decoration: BoxDecoration(
        color: bgColor ?? defaultToastBackgroundColor,
        boxShadow: defaultBoxShadow(),
        borderRadius: borderRadius ?? defaultToastBorderRadiusGlobal,
      ),
      padding: padding ?? EdgeInsets.symmetric(vertical: 16, horizontal: 30),
    ),
    gravity: gravity ?? defaultToastGravityGlobal,
    toastDuration: duration,
  );
  if (print) log(text);
}