This app focuses on adding Scaffolding and custom colors features of Flutter by following these steps:
project02 > lib > main.dart
-
final appBarColor = const Color(0xFFd2527f);
Declaring a customColor
for our AppBar. We usefinal
as we don't want the value ofappBarColor
to change anyhere throughout the app. Same goes for the use ofconst
. Flutter uses 32-bit ARGB value i.e. Alpha Red Green Blue for colors. Every color value begins with0x
(thinking why0x
?), next comes the opacity to use, we chooseFF
or full opaque without any transparency. Next up is our usual hex value ofd2527f
without any hash (#). -
final bgColor = const Color(0xFFe4e9ed);
Same goes for the background color for thehome
. -
home: Scaffold
Here we create aScaffold
. This is used to implement Material Design providing APIs for other material elements likeSnackBar
,Drawer
etc. -
backgroundColor: bgColor,
We use the declaredbgColor
inside theScaffold
to give it a value of0xFFe4e9ed
. -
appBar: AppBar
We initialise theAppBar
which is basically a material toolbar containing the app's name and/or other elements like logo and other actions (menu). -
backgroundColor: appBarColor
Finally, we do the same, apply the declaredappBarColor
to theAppBar
as its background color.