0Day Forums
What is the difference between Scaffold and MaterialApp in Flutter? - Printable Version

+- 0Day Forums (https://0day.red)
+-- Forum: Coding (https://0day.red/Forum-Coding)
+--- Forum: Flutter & Dart (https://0day.red/Forum-Flutter-Dart)
+--- Thread: What is the difference between Scaffold and MaterialApp in Flutter? (/Thread-What-is-the-difference-between-Scaffold-and-MaterialApp-in-Flutter)



What is the difference between Scaffold and MaterialApp in Flutter? - Sirchromolithograph0 - 07-21-2023

I have two screens, where
**First:** Listing of data from Firebase
**Second:** Add data in that screen so I want to comeback to first screen,
Everything working fine only there was a black screen when I go back.
Now issue was gone, I have searched for how it works but its still not clear my concept about this, Can any one describe how it works?

**Before**:

return new MaterialApp(
title: "AddEditNames ",
home: new AddEditNameScreen(),
);

**After**: when i have replaced it by

return new Scaffold(
backgroundColor: Color.fromRGBO(30, 30, 30, 1.0),
body: new AddEditNameScreen(),
appBar: new AppBar(
elevation: 0.0,
backgroundColor: Colors.blueAccent,
actions: <Widget>[
],
title: new Text(
"AddEditNames",
style: new TextStyle(color: Colors.white),
),
centerTitle: true,
),
);



RE: What is the difference between Scaffold and MaterialApp in Flutter? - Prolyric530 - 07-21-2023

`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(),
),
));
}


RE: What is the difference between Scaffold and MaterialApp in Flutter? - condenses222394 - 07-21-2023

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.


RE: What is the difference between Scaffold and MaterialApp in Flutter? - trended961740 - 07-21-2023

`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`][1] and [`Scaffold`][2].


[1]:

[To see links please register here]

[2]:

[To see links please register here]




RE: What is the difference between Scaffold and MaterialApp in Flutter? - hollownessesqxj - 07-21-2023

In Flutter, `MaterialApp` serves as the root widget for creating material design-based applications. It introduces essential components like navigation and themes to the app. On the other hand, `Scaffold` is a key component within `MaterialApp` that provides a structural layout for your app's user interface.

Think of `Scaffold` as a platform that offers a foundation for building your app's interface. It includes various built-in features such as `AppBar`, `BottomNavigationBar`, `Drawer`, `FloatingActionButton`, `BottomSheet`, and more. These features help you establish a consistent visual structure and enhance the user experience.

Essentially, `MaterialApp` sets the overall theme and navigation for your app, while `Scaffold` provides a ready-to-use layout structure with pre-defined widgets. You can customize and extend `Scaffold` to create your desired app layout and functionality.

It's worth noting that the term '**Scaffold**' itself implies a platform-like structure. Additionally, I mentioned '**root**,' which refers to the top-most widget in the widget hierarchy, serving as the starting point of your app.

Similar to Google's design system `MaterialApp` & `Scaffold`, for Apple's design system, we have `CupertinoApp` & `CupertinoPageScaffold` in Flutter.