Back to results for “Container)”
Flutter › Flutter Material Design Components

What is the Scaffold widget in Flutter, and how does it provide the basic overall visual structure for a typical Material Design screen, including an app bar, a body area, and a floating action button?

Beginner

Answer

Scaffold provides the basic, genuinely foundational visual structure and general overall layout for a typical Material Design screen, offering dedicated properties for commonly needed structural elements including an appBar displayed prominently at the very top of the screen, a body area representing the actual main visible content area, a floatingActionButton for a prominent primary action, and a drawer for a slide out side navigation menu, and using Scaffold as your genuine screen's root widget ensures these various common structural elements are all consistently and correctly positioned exactly according to Material Design's own well established layout conventions.
Scaffold(
  appBar: AppBar(title: Text('Orders')),
  body: OrderList(),
  floatingActionButton: FloatingActionButton(onPressed: addOrder, child: Icon(Icons.add)),
)
Real-world example An orders management screen uses Scaffold to properly and consistently structure its app bar, its main scrollable order list, and a floating action button specifically for quickly adding a genuinely new order, all correctly positioned exactly according to standard, well established Material Design conventions.

Common follow-ups: What happens if you try to use certain Material widgets without wrapping them somewhere within a Scaffold?;How do you properly show a temporary snackbar message from within a screen that already uses a Scaffold?