VisorVisor
FlutterWidgets

VisorSnackBar

Token-driven feedback toast with success, error, and standard variants. Static helper-method API — no constructor call required.

VisorSnackBar exposes a static-helper API for showing transient feedback toasts. Three variants — success, error, and standard — colour the surface from the semantic feedback palette. An optional action label and callback render an inline button.

Preview

When to Use

  • Confirming a completed action (save, submit, delete)
  • Reporting a transient error that does not block the current screen
  • Displaying a brief neutral status message (syncing, loading complete)
  • Providing an optional undo or retry action alongside the message

When Not to Use

  • Persistent errors that require user action (use an inline error or VisorErrorView)
  • Long messages with multiple actions (use a dialog or bottom sheet)
  • Blocking flows that must halt user interaction (use a modal dialog)
  • Content that should remain visible indefinitely (use a banner or alert card)

Installation

npx visor add snack-bar --target flutter

Or copy components/flutter/visor_snack_bar/visor_snack_bar.dart into your project.

Basic Usage

import 'package:ui/ui.dart';

VisorSnackBar.success(context, 'Project saved');

Variants

// Success — green surface
VisorSnackBar.success(context, 'Invitation sent');

// Error — red surface
VisorSnackBar.error(context, 'Could not save changes');

// Standard — neutral surface
VisorSnackBar.standard(context, 'Syncing…');

With Action

VisorSnackBar.standard(
  context,
  'Project archived',
  actionLabel: 'Undo',
  onAction: _undoArchive,
);

With Custom Duration

VisorSnackBar.error(
  context,
  'Network error — retrying in 5s',
  duration: const Duration(seconds: 5),
);

API Reference

VisorSnackBar exposes three static helpers — success, error, and standard — each with the same signature:

static void <variant>(
  BuildContext context,
  String message, {
  Duration? duration,
  String? actionLabel,
  VoidCallback? onAction,
});
ParameterTypeDefaultDescription
contextBuildContextrequiredBuild context — used to find ancestor ScaffoldMessenger
messageStringrequiredToast body text
durationDuration?platform defaultHow long the toast stays visible
actionLabelString?nullOptional label for the inline action button
onActionVoidCallback?nullFires when the action button is tapped

Accessibility

  • The toast surface is wrapped in Semantics(liveRegion: true) — TalkBack and VoiceOver announce the message on appearance (WCAG 4.1.3).
  • Action button (when present) meets the 48 dp tap-target floor.

Source

  • components/flutter/visor_snack_bar/visor_snack_bar.dart
  • Quality contract audit row: docs/flutter-widget-quality-contract.md (Rec8)