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.
Show temporary messages, confirmation dialogs and bottom sheets
Passing the Quiz & Exercises is mandatory to earn FX and proceed. If you fail, try again to gain the required FX, then the Proceed button will become available.
You can read this lesson publicly. Sign in to unlock exercises, quiz, and FX progress tracking.
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
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.
1// ── SnackBar - brief message at bottom of screen ──2ScaffoldMessenger.of(context).showSnackBar(3SnackBar(4content: const Text('Item deleted'),5action: SnackBarAction(6label: 'Undo',7onPressed: () => undoDelete(),8),9duration: const Duration(seconds: 3),10backgroundColor: Colors.green,11),12);
1// ── AlertDialog ──2showDialog(3context: context,4builder: (context) => AlertDialog(5title: const Text('Delete Item?'),6content: const Text('This action cannot be undone.'),7actions: [8TextButton(9onPressed: () => Navigator.pop(context), // dismiss10child: const Text('Cancel'),11),12ElevatedButton(13onPressed: () {14Navigator.pop(context); // close dialog15deleteItem();16},17child: const Text('Delete'),18),19],20),21);2223// ── ModalBottomSheet ──24showModalBottomSheet(25context: context,26shape: const RoundedRectangleBorder(27borderRadius: BorderRadius.vertical(top: Radius.circular(20)),28),29builder: (context) => Container(30padding: const EdgeInsets.all(24),31child: Column(32mainAxisSize: MainAxisSize.min,33children: [34const Text('Options', style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),35ListTile(leading: const Icon(Icons.share), title: const Text('Share')),36ListTile(leading: const Icon(Icons.delete), title: const Text('Delete')),37],38),39),40);
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.
Pick overlay type based on urgency and required decision:
Overusing high-interruption UI harms user flow. Use the least disruptive pattern that still communicates clearly.
Show temporary messages, confirmation dialogs and bottom sheets. This lesson adds one more building block for creating stable and user-friendly Flutter apps.
Build confidence with basics first; speed comes later.
After reading, rewrite the concept in your own words and apply it in a tiny runnable sample.
Each lesson becomes useful when you connect concept, implementation, and real-user outcome together.
SnackBar is designed for brief feedback messages. It appears at the bottom, auto-dismisses after a duration.
showDialog() is called with context and a builder function that returns the dialog widget.
Navigator.pop(context) removes the top route from the navigation stack. Since a dialog is a route, this closes it.
Something seems incorrect, unclear, or missing? Let us know.
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