showPrinterToast function
void
showPrinterToast(
- String message, {
- PrinterToastType type = PrinterToastType.info,
- BuildContext? context,
Shows a themed toast.
The toast is rendered in the host app's root overlay instead of a SnackBar, so the SDK never depends on the host's ScaffoldMessenger and can be driven from services and callbacks. Only one SDK toast is visible at a time; a new one replaces the previous one.
Implementation
void showPrinterToast(
String message, {
PrinterToastType type = PrinterToastType.info,
BuildContext? context,
}) {
final String text = message.trim();
if (text.isEmpty || !PrinterSdkConfig.showToasts) return;
final Color background = switch (type) {
PrinterToastType.success => PrinterSdkConfig.successColor,
PrinterToastType.error => PrinterSdkConfig.errorColor,
PrinterToastType.info => PrinterSdkConfig.primaryColor,
};
showPrinterToastWithColor(
text,
color: background,
context: context,
);
}