Questions And Answers

More Tutorials

Flutter Build widgets

Building Widgets

Flutter does the job of rendering the widgets on the screen for us (more on change detection & rendering later), but it needs configuration information for the widget: what color is it going to be, what is its border, does it contain other widgets....

Build Method

When it needs to know how to render a widget, Flutter calls the ‘build’ method in your widget. That method returns a Widget object that gives Flutter configuration information about the widget (and any child
widgets that it may be composed of).

class MyApp extends StatelessWidget {
// This widget is the root of your application.
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
home: Center(child:Text('Hello World'))

The ‘build’ method takes one argument, the BuildContext (more on that later) and returns a Widget object. That returned Widget object contains configuration data that tells Flutter that it needs to render a Material App widget with a title and some centered text.

Build Context

Earlier we mentioned that a widget can contain other widgets, in a tree structure, a hierarchy. This is often called a Widget Tree. The first argument to the build’ method of your Widget is the BuildContext. This gives your ‘build’ method information about the location of your Widget in the Widget Tree.
It may not seem useful at the moment but will come in very handy later on!


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

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:

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, you agree to have read and accepted our terms of use, cookies and privacy policy.