How to add a Background Images to the Screen?

This Article is posted by seven.srikanth at 12/25/2018 9:09:20 PM



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.


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