flutter change background color code example
Example 1: how to give your app background colour in flutter
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Welcome to Flutter',
home: Scaffold(
backgroundColor: Color(0xff00BCD1),
appBar: AppBar(
title: Text('Flutter Screen Background Color Example'),
),
body: Center(child: Body()),
),
);
}
}
class Body extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Text('How Are You?');
}
}
Example 2: how to change background color in flutter theme
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(
canvasColor: Colors.green,
),
home: Scaffold(
appBar: AppBar(
title: Text('Changing background color using theme'),
),
body: Container(
child: Center(
child: Text('Some widget goes here.')
)
),
),
);
}
}
Example 3: flutter scaffold background color
import 'package:flutter/material.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
title: 'Testing',
home: new Scaffold(
backgroundColor: Colors.white,
),
);
}
}
Example 4: background color flutter
backgroundColor: Colors.white