-- To create beautiful app we have to configure everything (backgroundColor,text etc.) by ourself manually even though flutter control everything on the screen but it does not add some extra component or widget by itself in existing app. so we have to give clear instruction about every details.
void main() => runApp(MyApp());
class MyApp extends StatelessWidget{
@override
Widget build(BuildContext context){
return MaterialApp(home: Scaffold())
}
}
-- So we have little helper Scaffold()
. Scaffold() has job to create base page design for us. so it will give you a basic design and structure and color scheme or coloring for giving you UI thats looks more like a regular mobile app page.
-- Scaffold has couple of named arguments. there are tons of it but u will use only few of them for widgets.
void main() => runApp(MyApp());
class MyApp extends StatelessWidget{
@override
Widget build(BuildContext context){
return MaterialApp(home: Scaffold(
appBar:AppBar(Text('AppBar')),
body:Text('This Is Body')
))
}
}
-- here for example we can add a appBar
and then a body . body is the basically the main content of the page. and appBar as name suggest it bar on the top. appBar takes a PerferredSizeWidget
its special kind of widget you can build it yourself but appBar is typical and specific thing in any App you can simply pass-in a prebuilt widget which is also name AppBar()
, all widgets are class so we are instantiating a class but this is a class which extends stateless and stateful in the end and AppBar takes some configuration there are bunch in it. you can pass actions which will be button in your appBar , you can add tabs if u want to add tabs in there. we can pass named-argument in that called title
which takes widget(Text()) not plain Text.
-- You compose your user interface by mixing multiple widgets together.
-- we can also add body
in scaffold.