show static method
void
show(
- BuildContext context, {
- required String message,
- Duration duration = const Duration(seconds: 2),
- Color? backgroundColor,
- Color? textColor,
Shows a toast message via the Overlay.
The toast appears at the bottom of the screen and is automatically removed
after duration elapses.
Implementation
static void show(
BuildContext context, {
required String message,
Duration duration = const Duration(seconds: 2),
Color? backgroundColor,
Color? textColor,
}) {
final overlay = Overlay.of(context);
if (overlay == null) return;
final entry = _buildOverlayEntry(
message,
backgroundColor: backgroundColor,
textColor: textColor,
);
overlay.insert(entry);
Future.delayed(duration, () {
if (entry.mounted) entry.remove();
});
}