show static method

void show(
  1. BuildContext context, {
  2. required String message,
  3. SubZeroToastType type = SubZeroToastType.defaultType,
  4. SubZeroToastPosition position = SubZeroToastPosition.bottom,
  5. SubZeroToastActionMode actionMode = SubZeroToastActionMode.icon,
  6. Duration duration = const Duration(seconds: 4),
  7. String? actionLabel,
  8. VoidCallback? onAction,
  9. IconData? leadingIcon,
  10. bool showCloseButton = true,
  11. double? maxWidth,
})

Shows a toast with full configuration

Implementation

static void show(
  BuildContext context, {
  required String message,
  SubZeroToastType type = SubZeroToastType.defaultType,
  SubZeroToastPosition position = SubZeroToastPosition.bottom,
  SubZeroToastActionMode actionMode = SubZeroToastActionMode.icon,
  Duration duration = const Duration(seconds: 4),
  String? actionLabel,
  VoidCallback? onAction,
  IconData? leadingIcon,
  bool showCloseButton = true,
  double? maxWidth,
}) {
  _dismiss();

  final config = SubZeroToastConfig(
    message: message,
    type: type,
    position: position,
    actionMode: actionMode,
    duration: duration,
    actionLabel: actionLabel,
    onAction: onAction,
    leadingIcon: leadingIcon,
    showCloseButton: showCloseButton,
    maxWidth: maxWidth,
  );

  final overlay = Overlay.of(context);
  _currentOverlay = OverlayEntry(
    builder: (context) => _SubZeroToastOverlay(
      config: config,
      onDismiss: _dismiss,
    ),
  );

  overlay.insert(_currentOverlay!);

  _dismissTimer = Timer(duration, _dismiss);
}