Material Widgets: Scaffold, Buttons, Cards and Dialogs

Google Flutter 13 min min read Updated: Nov 16, 2026 Beginner
Material Widgets: Scaffold, Buttons, Cards and Dialogs
Beginner Topic 6 of 9

Scaffold: The Page Layout

dart Scaffold( appBar: AppBar( title: const Text('My Shop'), actions: [ IconButton(icon: const Icon(Icons.search), onPressed: () {}), ], ), body: const Center(child: Text('Welcome')), floatingActionButton: FloatingActionButton( onPressed: () {}, child: const Icon(Icons.add), ), bottomNavigationBar: null, drawer: null, )
Scaffold partPurpose
appBarTop bar with title and actions
bodyMain content
floatingActionButtonMain action button, usually in the corner
drawerSide menu
bottomNavigationBarBottom tabs
backgroundColorPage color

Buttons

dart FilledButton(onPressed: () {}, child: const Text('Filled')) ElevatedButton(onPressed: () {}, child: const Text('Elevated')) OutlinedButton(onPressed: () {}, child: const Text('Outlined')) TextButton(onPressed: () {}, child: const Text('Text')) IconButton(onPressed: () {}, icon: const Icon(Icons.favorite)) ElevatedButton.icon( onPressed: () {}, icon: const Icon(Icons.shopping_cart), label: const Text('Add to cart'), ) // Disabled button: onPressed is null const ElevatedButton(onPressed: null, child: Text('Disabled'))

Styling a Button

dart ElevatedButton( onPressed: () {}, style: ElevatedButton.styleFrom( backgroundColor: Colors.deepPurple, foregroundColor: Colors.white, padding: const EdgeInsets.symmetric(horizontal: 32, vertical: 14), shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)), ), child: const Text('Continue'), )

Making Any Widget Tappable

dart InkWell( onTap: () => debugPrint('Tapped'), borderRadius: BorderRadius.circular(12), child: const Padding(padding: EdgeInsets.all(16), child: Text('Tap me')), ) GestureDetector( onTap: () {}, onLongPress: () {}, onDoubleTap: () {}, child: const FlutterLogo(size: 60), )

InkWell shows the Material ripple effect. GestureDetector has more gestures but no visual effect.

SnackBar

dart ScaffoldMessenger.of(context).showSnackBar( SnackBar( content: const Text('Item deleted'), action: SnackBarAction(label: 'UNDO', onPressed: () {}), ), );

AlertDialog

dart Future<void> confirmDelete(BuildContext context) async { final result = await showDialog<bool>( context: context, builder: (ctx) => AlertDialog( title: const Text('Delete item?'), content: const Text('This action cannot be undone.'), actions: [ TextButton(onPressed: () => Navigator.pop(ctx, false), child: const Text('Cancel')), FilledButton(onPressed: () => Navigator.pop(ctx, true), child: const Text('Delete')), ], ), ); if (result == true) debugPrint('Deleted'); }

Bottom Sheet

dart showModalBottomSheet( context: context, builder: (ctx) => const SizedBox( height: 200, child: Center(child: Text('Hello from the bottom')), ), );

Switch, Checkbox and Slider

dart Switch(value: isOn, onChanged: (v) => setState(() => isOn = v)) Checkbox(value: checked, onChanged: (v) => setState(() => checked = v ?? false)) Slider(value: volume, min: 0, max: 100, onChanged: (v) => setState(() => volume = v))
Tip: Use FilledButton for the main action, OutlinedButton or TextButton for secondary actions. This follows Material 3 guidelines.

Conclusion

Scaffold plus buttons, dialogs and bottom sheets cover the interface of most apps. The more Material widgets you know, the less you have to build yourself.

Quick Summary: Scaffold structures the page. Use FilledButton or ElevatedButton, InkWell for taps, and SnackBar, AlertDialog and bottom sheets for feedback.

Get Newsletter

Subscibe to our newsletter and we will notify you about the newest updates on Edugators