actionToast static method

void actionToast(
  1. BuildContext context, {
  2. required String message,
  3. List<ToastAction>? actions,
  4. Duration duration = const Duration(seconds: 3),
  5. Color background = const Color(0xFF2A3042),
})

Implementation

static void actionToast(
    BuildContext context, {
      required String message,
      List<ToastAction>? actions, // 0 to 3 buttons supported
      Duration duration = const Duration(seconds: 3),
      Color background = const Color(0xFF2A3042),
    }) {
  final overlay = Overlay.of(context);
  late OverlayEntry entry;

  entry = OverlayEntry(
    builder: (context) => _ToastWidget(
      message: message,
      background: background,
      actions: actions ?? [],
      onClose: () => entry.remove(),
    ),
  );

  overlay.insert(entry);

  Future.delayed(duration, () {
    if (entry.mounted) entry.remove();
  });
}