Flutter :- Material App

Pranesh Prashar
3 min readJan 2, 2022

In this we are going to see the use of the Material APP() in flutter

You can read the official docs here → https://api.flutter.dev/flutter/material/MaterialApp-class.html

let’s go on and start.

When we run the app just by returning the materialapp() then we can see an error has been caught by the widget library as this widget needs an argument .It is different from that of the material() which in return gave us white canvas.

Now we need to input the things that it needs.

The MaterialApp configures the top-level Navigator to search for routes in the following order:

1.For the / route, the home property, if non-null, is used.

2.Otherwise, the routes table is used, if it has an entry for the route.

3.Otherwise, onGenerateRoute is called, if provided. It should return a non- null value for any valid route not handled by home and routes.

4.Finally if all else fails on UnknownRoute is called.

Now let’s say we call the MaterialApp() and material app generally consists of home and body. We are going to build an app bar by calling app bar function in scaffold.

You can try to run this code. I have provided it below <**>

class myapp extends StatelessWidget {

@override

Widget build(BuildContext context) {

return MaterialApp(

home: Scaffold(

appBar: AppBar(

title: Text(“this is appbar by Pranesh Prashar”),

),

),

debugShowCheckedModeBanner: false,

);

}

}

The output result is this. So whenever we need to make an appbar we have to call this function.

Now this widget comes with many different combination for other widget so you can go and check the document for the other things.

One last thing that I want to show this widget comes with the body property.

One of the cool thing in scaffold is that I can change the color of the theme of the app bar according to choice given one of them is light and the other one is dark. So i choose the dark one and in the body property I call the center() and make text() it’s child and wrote a text as shown below.

THANK YOU FOR READING NEXT WE ARE GOING TO SEE SOME COOL STUFFS.

--

--