What is the difference between Scaffold and MaterialApp in Flutter?

MaterialApp is the starting point of your app, it tells Flutter that you are going to use Material components and follow material design in your app.

Scaffold is used under MaterialApp, it gives you many basic functionalities, like AppBar, BottomNavigationBar, Drawer, FloatingActionButton etc.

So, this is how a typical app starts with.

void main() {
  runApp(MaterialApp(
    home: Scaffold(
      appBar: AppBar(),
      body: YourWidget(),
    ),
  ));
}

The Material app is the core component and a predefined class. We can use the Material app to create widgets to design applications in Flutter. The Material app has several properties. Some of them are title, home, theme, color, routes, etc.

Scaffold is also another class which can be used to design application. It provides us APIs such as snack bars, bottom sheets, app bar, floating action bar, etc. Scaffold provides us a framework to implement the visual layout structure of the application.


MaterialApp is a widget that introduces a number of widgets (Navigator, Theme ) that are required to build a Material design app.

While Scaffold let you implement the material standard app widgets that most application has. Such as AppBar, BottomAppBar, FloatingActionButton, BottomSheet, Drawer, Snackbar.

The Scaffold is designed to be the single top-level container for a MaterialApp although it is not necessary to nest a Scaffold.

Also checkout official Flutter doc for MaterialApp and Scaffold.

Tags:

Dart

Flutter