bakeToast function
----------------------------------Toasts------------------------------------
Implementation
Future<void> bakeToast(String message,
{ToastType type = ToastType.normal}) async {
try {
Widget? _toast;
switch (type) {
case ToastType.normal:
_toast = DefaultToast(message: message, onToasted: _hideToast);
break;
case ToastType.info:
_toast = InfoToast(message: message, onToasted: _hideToast);
break;
case ToastType.success:
_toast = SuccessToast(message: message, onToasted: _hideToast);
break;
case ToastType.error:
_toast = ErrorToast(message: message, onToasted: _hideToast);
break;
case ToastType.warning:
_toast = WarningToast(message: message, onToasted: _hideToast);
break;
}
final child = Positioned(
left: 8.0,
right: 8.0,
bottom: 72.0,
child: Center(
child: _toast,
),
);
_printLog('''Showing Toast overlay''');
await _showOverlay(child: child, type: _OverlayType.Toast);
} catch (err) {
_printError('''Caught an exception while trying to show Toast''');
throw err;
}
}