Skip to main content

Toast

C2CToast is a custom widget in Flutter for displaying toast messages with various configurations such as message type, position, duration, and custom styles.

Methods

init(BuildContext context)

Initializes the C2CToast with the given context.

Note: By default, C2CCore.init() called this method. You don't need to call it again.

show({...})

Displays a toast message.

Parameters:

  • String? title: Optional title of the toast.
  • String? message: Message content of the toast.
  • BuildContext? context: The context where the toast is to be shown.
  • ToastType? type: The type of the toast.
  • ToastPosition position = ToastPosition.top: Position of the toast.
  • EdgeInsets? margin: Custom margin for the toast.
  • bool autoHide = true: Whether the toast should hide automatically.
  • Duration? duration: Duration for which the toast is visible.
  • bool dismissOnTap = true: Whether the toast should dismiss on tap.

hide()

Hides the currently displayed toast.

dismiss()

Dismisses all queued toasts and stops the current display.

Enumerations

ToastType

Specifies the type of the toast message.

  • success
  • error
  • warning
  • info

ToastPosition

Specifies the position of the toast message on the screen.

  • top
  • bottom