Carbon Flutter
  • Overview ⚡️
  • Installation ⚙️
  • Widgets 🧩
    • Breadcrumb
    • Button
    • Checkbox
    • Form
    • Icons
    • Link
    • Notification
    • OverflowMenu
    • Text
    • TextField
    • Toggle
Powered by GitBook
On this page
  • Overview
  • Widget API
  • Example

Was this helpful?

  1. Widgets 🧩

Notification

PreviousLinkNextOverflowMenu

Last updated 2 years ago

Was this helpful?

Overview

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

Widget API

Property
Description

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

Property
Description

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

lowContrast

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

  • Type: bool

  • Default: true

kind

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

  • Type: CNotificationKind

  • Default: CNotificationKind.info

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

caption

An optional caption to display.

  • Type: Widget?

  • Default: optional

Property
Description

child

The content of the action button.

  • Type: Widget

  • Default: required

onTap

Called when the action button is tapped.

  • Type: VoidCallback

  • Default: required

width

The width of the action button. If it's null, the action button will size itself to the child.

  • Type: double?

  • Default: optional

height

The height of the action button. If it's null, the action button will size itself to the child.

  • Type: double?

  • 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: () {}),
  ],
)