Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 320 Vote(s) - 3.59 Average
  • 1
  • 2
  • 3
  • 4
  • 5
What is the difference between Scaffold and MaterialApp in Flutter?

#1
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,
),
);
Reply

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

#3
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.
Reply

#4
`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]

Reply

#5
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.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through