flutter container background image code example
Example 1: background color to container flutter
new Container(
width: 100,
height: 30,
decoration: new BoxDecoration(
color: Colors.green
),
)
Example 2: flutter background image
Widget build(BuildContext context) {
return MaterialApp(
title: 'Welcome to Flutter',
home: Container(
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage("images/logo.png"), fit: BoxFit.cover)),
child: Scaffold(
backgroundColor: Colors.transparent,
appBar: AppBar(
elevation: 0,
backgroundColor: Colors.transparent,
title: Text('My App'),
centerTitle: true,
leading: IconButton(
icon: Icon(
Icons.list,
color: Colors.white,
),
onPressed: () {}),
),
),
),
);
}
Example 3: add bg image to scaffold flutter
@override
Widget build(BuildContext context) {
return new Scaffold(
body: new Stack(
children: <Widget>[
new Container(
decoration: new BoxDecoration(
image: new DecorationImage(image: new AssetImage("images/background.jpg"), fit: BoxFit.cover,),
),
),
new Center(
child: new Text("Hello background"),
)
],
)
);
}
Example 4: 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,
),
);
}
}