showWebToast method
dynamic
showWebToast(})
Implementation
showWebToast(String msg, String gravity,
{int duration = 1000,
String bgcolor = "linear-gradient(to right, #00b09b, #96c93d)",
bool showClose = false,
String? textColor}) {
String message = msg.replaceAll("'", "\\'").replaceAll("\n", "<br />");
html.Element? ele = html.querySelector("#toast-content");
String content = """
var toastElement = Toastify({
text: '$message',
gravity: '$gravity',
position: 'center',
duration: $duration,
close: $showClose,
backgroundColor: "$bgcolor",
});
toastElement.showToast();
""";
if (html.querySelector("#toast-content") != null) {
ele!.remove();
}
final html.ScriptElement scriptText = html.ScriptElement()
..id = "toast-content"
..innerHtml = content;
html.querySelector('head')!.children.add(scriptText);
if (textColor != null) {
html.Element toast = html.querySelector('.toastify')!;
String tcRadix = textColor;
final String tC = "${tcRadix.substring(2)}${tcRadix.substring(0, 2)}";
toast.style.setProperty('color', "#$tC");
}
}