MOCKSTACKS
EN
Questions And Answers

More Tutorials









Flutter App Scaffolding Widgets


Flutter makes it easy to generate a default mobile app and you quickly end up with something like this, something surprisingly sophisticated with Color themes, an App Bar, a Content Area with a Count and a Floating Button.

The reason you quickly get something sophisticated is that the Default App uses Flutter Widgets that were specially designed to scaffold an app as quickly as possible.

The purpose of this chapter is to cover these Widgets.
When your code entry point runs (i.e. the main method), it calls runApp to initialize a given widget (an App Widget). The build method of the App Widget is invoked and it returns a MaterialApp object, which gives Flutter the information it needs to generate the widget and display it on the screen, along with its child Widgets.

So, your App Widget returns a MaterialApp that you have initialized with the title, theme and home properties initialized. It’s called a
Material App because this class builds the foundations for an app that uses Google’s Material Design UI.

MaterialApp


Builds the foundations for a cross-platform app that uses Google’s Material Design UI.
It introduces built-in objects such as the Navigator, Themes and Locales to help you develop your app.

Navigator


We will cover the Navigator in a later chapter.

Themes


When you build a Flutter app, you build a root Widget. That Widget usually returns a MaterialApp, which builds the foundations for the
app. One of the constructor arguments for MaterialApp is the Theme object. This object specifies the colors to be used in the application’s Widgets. As you can see below the user can pass in Theme data into the MaterialApp constructor using a ThemeData object.
Default Flutter App Uses Blue Theme

class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return new MaterialApp(
title: 'Flutter Demo',
theme: new ThemeData(
primarySwatch: Colors.blue,
),
home: new MyHomePage(title: 'Flutter Demo Home Page'),
debugShowMaterialGrid: true,
debugShowCheckedModeBanner: false,
showPerformanceOverlay: true,
);
}
}

Example of Darkening Theme

Source Code


This is the default Flutter app with just a change to the accent color and the brightness.

class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return new MaterialApp(
title: 'Flutter Demo',
theme: new ThemeData(
accentColor: Colors.redAccent,
brightness: Brightness.dark),
home: new MyHomePage(title: 'Flutter Demo Home Page'),
);
}



Conclusion

In this page (written and validated by ) you learned about Flutter App Scaffolding Widgets . What's Next? If you are interested in completing Flutter tutorial, your next topic will be learning about: Flutter Builders.



Incorrect info or code snippet? We take very seriously the accuracy of the information provided on our website. We also make sure to test all snippets and examples provided for each section. If you find any incorrect information, please send us an email about the issue: mockstacks@gmail.com.


Share On:


Mockstacks was launched to help beginners learn programming languages; the site is optimized with no Ads as, Ads might slow down the performance. We also don't track any personal information; we also don't collect any kind of data unless the user provided us a corrected information. Almost all examples have been tested. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. By using Mockstacks.com, you agree to have read and accepted our terms of use, cookies and privacy policy.