showMessage method

dynamic showMessage(
  1. String message, {
  2. String title = "Message",
  3. Widget? titleWidget,
  4. Widget? messageWidget,
  5. MessageType type = MessageType.info,
  6. MessageStyle style = MessageStyle.flatColored,
  7. bool autoClose = true,
  8. int autoCloseDurationSeconds = 5,
  9. Alignment alignment = Alignment.bottomRight,
  10. TextDirection textDirection = TextDirection.ltr,
  11. bool showAnimation = false,
  12. int animationDurationMillis = 300,
  13. Widget? customIcon,
})

Use showMessage without context if you are using PlexApp

Implementation

showMessage(
  String message, {
  String title = "Message",
  Widget? titleWidget,
  Widget? messageWidget,
  MessageType type = MessageType.info,
  MessageStyle style = MessageStyle.flatColored,
  bool autoClose = true,
  int autoCloseDurationSeconds = 5,
  Alignment alignment = Alignment.bottomRight,
  TextDirection textDirection = TextDirection.ltr,
  bool showAnimation = false,
  int animationDurationMillis = 300,
  Widget? customIcon,
}) {
  toastification.show(
    type: type.type,
    style: style.style,
    autoCloseDuration: autoClose ? Duration(seconds: autoCloseDurationSeconds) : null,
    title: titleWidget ?? Text(title),
    description: messageWidget ?? Text(message),
    alignment: alignment,
    direction: textDirection,
    animationDuration: showAnimation ? Duration(milliseconds: animationDurationMillis) : null,
    animationBuilder: showAnimation
        ? (context, animation, alignment, child) {
            return FadeTransition(
              opacity: animation,
              child: child,
            );
          }
        : null,
    icon: customIcon,
    boxShadow: const [
      BoxShadow(
        color: Color(0x07000000),
        blurRadius: 16,
        offset: Offset(0, 16),
        spreadRadius: 0,
      )
    ],
    showProgressBar: autoClose,
    closeButtonShowType: CloseButtonShowType.onHover,
    closeOnClick: false,
    pauseOnHover: true,
    dragToClose: true,
    applyBlurEffect: true,
    callbacks: ToastificationCallbacks(
      onTap: (toastItem) => print('Toast ${toastItem.id} tapped'),
      onCloseButtonTap: (toastItem) {
        print('Toast ${toastItem.id} close button tapped');
        toastification.dismissById(toastItem.id);
      },
      onAutoCompleteCompleted: (toastItem) => print('Toast ${toastItem.id} auto complete completed'),
      onDismissed: (toastItem) => print('Toast ${toastItem.id} dismissed'),
    ),
  );
}