Notification

Overview

Notifications are messages that communicate information to the user. The two main variants of notifications are toast notifications and inline notifications.

Widget API

PropertyDescription

title

The title to display.

  • Type: Widget

  • Default: required

subtitle

The subtitle to display.

  • Type: Widget

  • Default: required

hideCloseButton

Whether the close button should be disabled, or not.

  • Type: bool

  • Default: false

kind

The state that the notification represents. It can be error, info, success, or warning.

  • Type: CNotificationKind

  • Default: CNotificationKind.info

lowContrast

Whether you are using the low contrast variant of the notification.

  • Type: bool

  • Default: true

onCloseButtonTap

Called when the close button is tapped.

  • Type: VoidCallback?

  • Default: optional

onClose

Called after the given timeout duration has passed.

  • Type: VoidCallback?

  • Default: optional

actions

A list of CNotificationActionButton to display in a row when the notification is inline.

  • Type: List<CNotificationActionButton>?

  • Default: optional

Example

CNotification.toast(
  onCloseButtonTap: () {},
  lowContrast: false,
  kind: CNotificationKind.error,
  title: CText(data: 'Notification title'),
  subtitle: CText(data: 'Subtitle text goes here.'),
  caption: CText(data: 'Time stamp [00:00:00]'),
)

// OR

CNotification.inline(
  onCloseButtonTap: () {},
  kind: CNotificationKind.success,
  lowContrast: false,
  title: CText(data: 'Notification title'),
  subtitle: CText(data: 'Subtitle text goes here.'),
  actions: [
    CNotificationActionButton(child: CText(data: 'Action'), onTap: () {}),
  ],
)

Last updated