Flutter SDK Set Background image

后端 未结 10 1823
礼貌的吻别
礼貌的吻别 2020-11-30 20:38

I am trying to set a background image for the home page. I am getting the image place from start of the screen and filling the width but not the height. Am I missing someth

10条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-30 21:04

    To set a background image without shrinking after adding the child, use this code.

      body: Container(
        constraints: BoxConstraints.expand(),
          decoration: BoxDecoration(
            image: DecorationImage(
                image: AssetImage("assets/aaa.jpg"),
            fit: BoxFit.cover,
            )
          ),
    
        //You can use any widget
        child: Column(
          children: [],
        ),
        ),
    

提交回复
热议问题