How to add a Background Images to the Screen?

This Article is posted by seven.srikanth at 25-12-2018 21:09:20

You can do this by using DecoratedBox Widget. The example code below.

Note: You can observe that Child of DecoratedBox doesn't have any code. If you are trying this example, you need to add image to your project and also add some widgets to Child within DecoaratedBox.

import 'package:flutter/material.dart';

void main() => runApp(BackgroundScreen());

class BackgroundScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Backgroun Image',
home: Scaffold(
body: DecoratedBox(
position: DecorationPosition.background,
decoration: BoxDecoration(
color: Colors.red,
image: DecorationImage(
image: AssetImage('Images/Landscape.jpg'),
fit: BoxFit.cover),
),
child:
//Rest of the widgets go here..
)
),
);
}
}


Thanks,
Srikanth

Tags: How to add a Background Images to the Screen?



0 Comments
Login to comment.
Recent Comments

Be the first to Comment. You can ask a Query or Share your toughts or Just say thanks.



Recent Articles


How to deploy flutter web site on GitHub using peanut

Posted by nikhilchaudhary12155 on 13 Oct 2019 Article


AnimatedPositioned Widget Example in Flutter

Posted by seven.srikanth on 10 Oct 2019 Article


Flutter Open-Source and directory lists

Posted by nishantkotatech on 09 Oct 2019 Article


Flutter Travelling Couple Leading Page - Flutter Web Series 3

Posted by nikhilchaudhary12155 on 05 Oct 2019 Article



© 2018 - Fluttercentral | Email to me - Seven.srikanth@gmail.com