Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between Scaffold and MaterialApp in Flutter?

Tags:

flutter

dart

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,       ),  ); 
like image 700
Richa Shah Avatar asked Mar 29 '19 06:03

Richa Shah


People also ask

What is the difference between MaterialApp and Scaffold 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.

What is a MaterialApp in Flutter?

MaterialApp Class: MaterialApp is a predefined class in a flutter. It is likely the main or core component of flutter. We can access all the other components and widgets provided by Flutter SDK.

What is the difference between material and MaterialApp in Flutter?

MaterialApp is a widget that introduces many interesting tools such as Navigator or Theme to help you develop your app. Material is, on the other hand, a widget used to define a UI element respecting Material rules. It defines what elevation is, shape, and stuff.

What is a Scaffold in Flutter?

The Scaffold is a widget in Flutter used to implements the basic material design visual layout structure. It is quick enough to create a general-purpose mobile application and contains almost everything we need to create a functional and responsive Flutter apps. This widget is able to occupy the whole device screen.


Video Answer


1 Answers

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(),     ),   )); } 
like image 195
CopsOnRoad Avatar answered Oct 05 '22 22:10

CopsOnRoad