show static method
void
show(})
Implementation
static void show(String msg,
{int? duration = 1,
int? gravity = 0,
Color backgroundColor = const Color(0xAA000000),
textStyle = const TextStyle(fontSize: 15, color: Colors.white),
double backgroundRadius = 20,
bool? rootNavigator,
Border? border,
bool webShowClose = false,
Color webTexColor = const Color(0xFFffffff)}) {
if (ToastContext().context == null) {
throw Exception('Context is null, please call ToastContext.init(context) first');
}
if (kIsWeb == true) {
if (ToastContext()._channel == null) {
ToastContext()._channel = const MethodChannel('appdev/FlutterToast');
}
String toastGravity = "bottom";
if (gravity == Toast.top) {
toastGravity = "top";
} else if (gravity == Toast.center) {
toastGravity = "center";
} else {
toastGravity = "bottom";
}
final Map<String, dynamic> params = <String, dynamic>{
'msg': msg,
'duration': (duration ?? 1) * 1000,
'gravity': toastGravity,
'bgcolor': backgroundColor.toString(),
'textcolor': webTexColor.value.toRadixString(16),
'webShowClose': webShowClose,
};
ToastContext()._channel?.invokeMethod("showToast", params);
} else {
ToastView.dismiss();
ToastView.createView(msg, ToastContext().context!, duration, gravity, backgroundColor,
textStyle, backgroundRadius, border, rootNavigator);
}
}