import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:flutter/material.dart'; import 'package:fluttertoast/fluttertoast.dart'; class AppToast { static void showToast({ @required String message, Toast toastLength, int timeInSeconds, double fontSize, ToastGravity toastGravity, Color backgroundColor, Color textColor, int radius, int elevation, int imageSize, }) { Fluttertoast.showToast( msg: message, toastLength: toastLength, gravity: toastGravity, timeInSecForIosWeb: timeInSeconds, backgroundColor: backgroundColor, textColor: textColor, fontSize: fontSize); } static void showSuccessToast({ @required String message, Toast toastLength = Toast.LENGTH_LONG, int timeInSeconds, double fontSize = 16, ToastGravity toastGravity = ToastGravity.TOP, Color textColor = Colors.white, int radius, int elevation, int imageSize = 32, }) { Fluttertoast.showToast(msg: message, toastLength: toastLength, gravity: toastGravity, timeInSecForIosWeb: timeInSeconds, backgroundColor: Colors.green, textColor: textColor, fontSize: fontSize); } static void showErrorToast({ @required String message, Toast toastLength = Toast.LENGTH_LONG, int timeInSeconds = 2, double fontSize = 16, ToastGravity toastGravity = ToastGravity.TOP, Color textColor = Colors.white, int radius = 15, int elevation, int imageSize = 32, }) { Fluttertoast.showToast(msg: message, toastLength: toastLength, gravity: toastGravity, timeInSecForIosWeb: timeInSeconds, backgroundColor: Colors.red, textColor: textColor, fontSize: fontSize); } void cancelToast() { Fluttertoast.cancel(); } void backWithEmpty() { AppToast.showErrorToast(message: TranslationBase.of(AppGlobal.context).empty); Navigator.of(AppGlobal.context).pop(); } void back() { Navigator.of(AppGlobal.context).pop(); } }