import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:fluttertoast/fluttertoast.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; class ToastUtils { static void getFluttertoast({ required BuildContext context, required String msg, Toast? toastLength, int timeInSecForIosWeb = 1, double? fontSize, ToastGravity? gravity, Color? backgroundColor, Color? textColor, }) { Fluttertoast.showToast( msg: msg, toastLength: toastLength ?? Toast.LENGTH_SHORT, gravity: gravity ?? ToastGravity.CENTER, timeInSecForIosWeb: timeInSecForIosWeb, backgroundColor: backgroundColor ?? Theme.of(context).primaryColor, textColor: textColor ?? Colors.white, fontSize: fontSize ?? 16.sp, ); } static void getErrFluttertoast({ required BuildContext context, required String msg, ToastGravity gravity = ToastGravity.BOTTOM, Color backgroundColor = Colors.grey, Toast? toastLength, int timeInSecForIosWeb = 1, double? fontSize, Color? textColor, }) { ToastUtils.getFluttertoast( context: context, msg: msg, toastLength: toastLength ?? Toast.LENGTH_SHORT, gravity: gravity, timeInSecForIosWeb: timeInSecForIosWeb, backgroundColor: backgroundColor, textColor: textColor ?? Colors.white, fontSize: fontSize ?? 16.sp, ); } static showError(String showMsg, {Duration? duration}) { EasyLoading.showError(showMsg, duration: duration); } static showLoading() { EasyLoading.show(status: 'loading...'); } static showInfo(String showMsg, {Duration? duration}) { EasyLoading.showInfo(showMsg, duration: duration); } static showInfoSimple(String showMsg, int microseconds) { EasyLoading.showInfo(showMsg, duration: Duration(microseconds: microseconds)); } static showSuccess(String showMsg, {Duration? duration}) { EasyLoading.showSuccess(showMsg, duration: duration); } static dismiss() { EasyLoading.dismiss(); } }