Flutter SDK Set Background image

后端 未结 10 1818
礼貌的吻别
礼貌的吻别 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:18

    You can use Stack to make the image stretch to the full screen.

    Stack(
            children: 
            [
              Positioned.fill(  //
                child: Image(
                  image: AssetImage('assets/placeholder.png'),
                  fit : BoxFit.fill,
               ),
              ), 
              ...... // other children widgets of Stack
              ..........
              .............
             ]
     );
    

    Note: Optionally if are using a Scaffold, you can put the Stack inside the Scaffold with or without AppBar according to your needs.

提交回复
热议问题