Skip to content
Get started
Menu
Get started

Banner

PaymentBanner explains something on the page where it applies: a total that changed, a method that is unavailable, a status that is not confirmed yet. It stays until the situation changes.

Information, changed total and payment error banners with review, retry and support actions.Information, changed total and payment error banners with review, retry and support actions.
Banner
Information, changed total and payment error banners with review, retry and support actions at 200 percent text.
200% text
Information, changed total and payment error banners with review, retry and support actions, in Indonesian.
Indonesian
example/lib/screens/steps/kyc_onboarding_step.dart
PaymentBanner(tone: StatusTone.warning, title: s.fixHighlighted);

Variants: neutral, info, success, warning, danger.

tone sets the fill, the title color and the default icon. Pass icon to replace the default.

Tone Default icon Use it for
info, neutral Icons.info_outline An explanation, such as how long a transfer takes.
success Icons.check_circle_outline A confirmed result worth calling out on the page.
warning Icons.warning_amber_outlined Something to review before going on, such as a changed total.
danger Icons.error_outline A failure that blocks the next step.

One layout in every tone:

[icon] Title [×]
Message, one or two lines
[Action] Secondary link
  • Icon: 20 dp, centred on the title’s first line, never on the whole block. It grows with the text up to 1.6×.
  • Text column: the title, message and actions share one start edge. Title → message is 4, and message → actions is 8.
  • Close (×): shown when onDismiss is set. Its glyph centres on the title’s first line, and its 48 dp target overlaps the 12 dp padding instead of growing the title row. A dismissible banner is exactly as tall as the same banner without close.
  • Padding: 12 on all sides.

actions takes at most one hug secondary PaymentButton plus at most one PaymentLink, shown in the text column in a row that wraps. Use a button for an operation (“Try again”) and a link for navigation (“Review total”). Never use two buttons of equal weight. The banner draws its button at the small size, and a debug assert rejects anything else.

PaymentBanner(
tone: StatusTone.danger,
title: 'Payment failed',
message: 'Your balance has not changed.',
actions: [
PaymentButton(
label: 'Try again',
variant: PaymentButtonVariant.secondary,
width: PaymentWidth.hug,
onPressed: host.retry,
),
PaymentLink(label: 'Contact support', onPressed: host.openSupport),
],
);

A banner about a changed payment amount states old → new, for example “Was Rp102.500, now Rp104.000”. It has no onDismiss while the payment is open, so the only cue that the total changed cannot be hidden before paying. The same rule covers a danger banner that blocks the flow. PaymentSummary shows such a banner after a re-quote, using totalChangedMessage.

Migration (UI review P2): the tightened assert rejects a second button, a quiet button and a second link. Turn the extra action into a PaymentLink, and remove onDismiss from a total-changed banner.

announce: true makes the banner a live region, so screen readers read it when it appears. Use it for a banner that appears in response to something, such as a re-quote or a failed request. Leave it off for a banner that is part of the page from the start.

Use onDismiss for a Hide banner action reported once; the host removes the banner. Actions accept at most one hug secondary PaymentButton plus one PaymentLink.

Situation Variant / composition Payment example
History failed to load danger Use warning for a supporting module failure; danger when primary content failed.

Use Toast for feedback after an action.

Keep the banner visible while its message applies. Supply onDismiss only when the person may safely hide it; a changed-total notice stays visible through review.

Do: Use warning for a supporting module failure; danger when primary content failed.

Don’t: Turn an unknown payment into failed because a side request failed.

  • The title says what happened in a few words: “Total changed”, “Method unavailable”.
  • The message says what it means for the person and what to do next, in one or two sentences.
  • Do not stack banners. Show the one that matters most.
  • Use a toast for passing feedback that does not need to stay on screen.
  • The tone always comes with an icon and a title, so color is not the only signal.
  • The icon grows with text size up to 1.6× and stays centered on the title’s first line however far the title wraps. The close button’s label is “Hide banner:” followed by the title.
  • The banner is one semantics container, so its title and message are read together.

PaymentBanner

class PaymentBanner extends StatefulWidget · lib/src/foundation/primitives.dart

Inline message for errors, warnings and explanations.

One anatomy in every tone (D48a): the 20 dp tone icon centres on the title's first line; title, message and actions share one text column (title → message 4, message → actions 8); the close button centres on the first line and its 48 dp target overlaps the 12 dp padding, so a dismissible banner is as tall as the same banner without close.

Actions are at most one hug secondary PaymentButton (an operation such as "Try again", drawn small) plus at most one PaymentLink (navigation such as "Review total"), never two buttons of equal weight.

A banner about a changed payment amount states old → new and has no onDismiss while the payment is open (D48), like a danger banner that blocks the flow.

ParameterTypeDefaultDescription
tone:requiredStatusTone—Semantic message tone.
title:requiredString—Visible banner heading.
message:String?—Optional explanation.
icon:IconData?—Default trigger glyph.
actions:List<Widget>const []At most one hug secondary PaymentButton plus one PaymentLink.
announce:boolfalseAnnounces the banner to screen readers when it appears.
onDismiss:VoidCallback?—Shows Hide banner; reports at most once. The host removes the banner. Leave it null on a changed-amount banner while the payment is open.

NoticeBanner

typedef NoticeBanner = PaymentBanner · lib/src/foundation/primitives.dart

Deprecated. Use PaymentBanner.

Deprecated alias of PaymentBanner.

NoticeBanner is a deprecated alias. Replace the constructor name with PaymentBanner; existing arguments keep compiling.