Learn/Core Widgets/Snackbar, Dialogs & BottomSheet

Snackbar, Dialogs & BottomSheet

Show temporary messages, confirmation dialogs and bottom sheets

5 min~4 min read+30 FX

You can read this lesson publicly. Sign in to unlock exercises, quiz, and FX progress tracking.

Table of Contents

  1. 1. Choosing The Right Level Of Interruption
  2. 2. This Lesson In Simple Words
  3. 3. Your level focus
  4. 4. One practical habit
  5. 5. Deep Understanding Guide
  6. 6. Why this lesson matters
  7. 7. Study flow for better retention

Having trouble? AI is here to help

Ask context-aware questions about this lesson. Free plan: 5 questions/day. Upgrade to Premium for higher daily limits.

Use the AI button at the bottom of the screen

Snackbar, Dialogs & BottomSheet

These are the three main ways to show overlay content to users in Flutter. Each one serves a different purpose depending on how much attention you need from the user and how long the message should remain visible.

dart
1// ── SnackBar - brief message at bottom of screen ──
2ScaffoldMessenger.of(context).showSnackBar(
3 SnackBar(
4 content: const Text('Item deleted'),
5 action: SnackBarAction(
6 label: 'Undo',
7 onPressed: () => undoDelete(),
8 ),
9 duration: const Duration(seconds: 3),
10 backgroundColor: Colors.green,
11 ),
12);
dart
1// ── AlertDialog ──
2showDialog(
3 context: context,
4 builder: (context) => AlertDialog(
5 title: const Text('Delete Item?'),
6 content: const Text('This action cannot be undone.'),
7 actions: [
8 TextButton(
9 onPressed: () => Navigator.pop(context), // dismiss
10 child: const Text('Cancel'),
11 ),
12 ElevatedButton(
13 onPressed: () {
14 Navigator.pop(context); // close dialog
15 deleteItem();
16 },
17 child: const Text('Delete'),
18 ),
19 ],
20 ),
21);
22
23// ── ModalBottomSheet ──
24showModalBottomSheet(
25 context: context,
26 shape: const RoundedRectangleBorder(
27 borderRadius: BorderRadius.vertical(top: Radius.circular(20)),
28 ),
29 builder: (context) => Container(
30 padding: const EdgeInsets.all(24),
31 child: Column(
32 mainAxisSize: MainAxisSize.min,
33 children: [
34 const Text('Options', style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),
35 ListTile(leading: const Icon(Icons.share), title: const Text('Share')),
36 ListTile(leading: const Icon(Icons.delete), title: const Text('Delete')),
37 ],
38 ),
39 ),
40);

When to Use Each

💡 When to Use Each

SnackBar is for brief feedback such as saved, deleted, or error messages. AlertDialog is for situations where confirmation is needed before an action, such as delete or logout. BottomSheet is for presenting a selection of options, a share sheet, or a settings panel.

Choosing The Right Level Of Interruption

Pick overlay type based on urgency and required decision:

  • Low interruption: SnackBar for status updates
  • Medium interruption: BottomSheet for optional choices
  • High interruption: AlertDialog for risky confirmations

Overusing high-interruption UI harms user flow. Use the least disruptive pattern that still communicates clearly.

Overlay Decision Checklist

  • Does user need to stop and decide now, or just be informed?
  • Can the same feedback be shown as non-blocking SnackBar?
  • Is destructive action protected by explicit confirmation?
  • Is dismissal behavior obvious and accessible?

This Lesson In Simple Words

Show temporary messages, confirmation dialogs and bottom sheets. This lesson adds one more building block for creating stable and user-friendly Flutter apps.

Your level focus

Build confidence with basics first; speed comes later.

One practical habit

After reading, rewrite the concept in your own words and apply it in a tiny runnable sample.

Deep Understanding Guide

Why this lesson matters

Each lesson becomes useful when you connect concept, implementation, and real-user outcome together.

Study flow for better retention

  1. Read one section, run one tiny example, then explain the idea in your own words.
  2. Use a simple cycle: understand, implement, test, and explain.
  3. If you can teach it in 45 seconds without notes, you understood it.

Common Mistakes To Avoid

  • Moving forward without checking whether the current concept is truly clear.
  • Copying code exactly without experimenting with small changes.
  • Skipping edge cases and only testing happy-path behavior.
  • Assuming one pattern works for every scenario without trade-off analysis.

Practice Sprint (15-25 Minutes)

  • Before running sample code, predict output and behavior in one sentence.
  • Build one tiny example from memory after finishing this lesson.
  • Write one paragraph about where this concept fits in a real app.
  • Create one failure scenario and verify your app handles it safely.
  • Complete the required exercises without using hints on the first attempt.
  • Answer this question out loud before checking quiz options: "Which widget is best for a brief "Item saved" message?".

Code Comprehension Drill

  • State the purpose of the code block in one line before reading details.
  • Mark inputs, state changes, and final output.
  • Change one small value and predict what should happen before running.
  • Run again and compare your prediction with actual behavior.

Lesson Completion Checklist

  • I can explain "Snackbar, Dialogs & BottomSheet" in simple words without reading notes.
  • I can describe one real app situation where this concept is required.
  • I know at least one mistake to avoid: Moving forward without checking whether the current concept is truly clear.
  • I can modify one code sample and correctly predict the behavior change.
  • I can finish required exercises with understanding, not trial-and-error guesses.

Frequently Asked Questions

Which widget is best for a brief "Item saved" message?

SnackBar is designed for brief feedback messages. It appears at the bottom, auto-dismisses after a duration.

How do you show an AlertDialog in Flutter?

showDialog() is called with context and a builder function that returns the dialog widget.

What does Navigator.pop(context) do inside a dialog?

Navigator.pop(context) removes the top route from the navigation stack. Since a dialog is a route, this closes it.

Suggest Improvement

Something seems incorrect, unclear, or missing? Let us know.

About The Author

FlutterCraft editorial lessons are reviewed by experienced Flutter developers and updated to stay aligned with modern Flutter and Dart best practices.

Reference docs: Flutter Documentation, Dart Language Tour, and official package documentation where relevant.

Sign in to continue with exercises and quiz for this lesson.

Sign In to Continue