Scaffold widget is a material design widget for simple and better first page view. Scaffold widget supports multiple type of argument and one them is backgroundColor. backgroundColor is used to Set Background Color of Scaffold Widget Main Home Screen in Flutter android iOS mobile application. We can change the complete application home screen background color using this.
Contents in this project Set Background Color of Scaffold Widget Main Home Screen in Flutter:
1. Import material.dart package in your main.dart file.
1 |
import 'package:flutter/material.dart'; |
2. Create the Void Main() function and call our main MyApp class using runApp() method.
1 |
void main() => runApp(MyApp()); |
3. Create our main View class named as MyApp extends with StatelessWidget.
1 2 3 |
class MyApp extends StatelessWidget { } |
4. Create Widget build method in MyApp class.
1 2 3 4 5 6 7 8 9 |
class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( home: ); } } |
5. Create Scaffold widget in home section of Material App.
backgroundColor : Used to set the background color of complete app home screen.
Here Color format is 0xff + HEX Color code.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( backgroundColor: Color(0xff84FFFF), body: SafeArea( child: Center( child: ( Text('Set Scaffold Background Color') ) ) ) ) ); } } |
6. Complete source code for main.dart file:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
import 'package:flutter/material.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( backgroundColor: Color(0xff84FFFF), body: SafeArea( child: Center( child: ( Text('Set Scaffold Background Color') ) ) ) ) ); } } |
Screenshot:
Hii Sir,
How to save json api response of post type in sqllite database flutter
Navtej currently i am working on SQLite database, when its completed i will post the tutorial.