showExportToast function
- BuildContext context,
- String message, {
- Duration duration = const Duration(seconds: 3),
Show a brief floating toast at the bottom of the screen.
Works without a Scaffold ancestor by inserting directly into the
root Overlay. Auto-removes after duration.
Implementation
void showExportToast(
BuildContext context,
String message, {
Duration duration = const Duration(seconds: 3),
}) {
final overlay = Overlay.of(context, rootOverlay: true);
late OverlayEntry entry;
entry = OverlayEntry(
builder: (ctx) => Positioned(
bottom: 32,
left: 0,
right: 0,
child: Center(
child: Material(
elevation: 4,
borderRadius: BorderRadius.circular(8),
color: Colors.grey.shade800,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10),
child: Text(
message,
style: const TextStyle(color: Colors.white, fontSize: 13),
),
),
),
),
),
);
overlay.insert(entry);
Timer(duration, entry.remove);
}