Make AppBar transparent and show background image which is set to whole screen

后端 未结 9 1468
滥情空心
滥情空心 2020-12-28 12:42

I have added AppBar in my flutter application. My screen already have a background image, where i don\'t want to set appBar color or don\'t want set separat

9条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-28 13:04

    Output:

    A lot of answers but nobody explains why extendBodyBehindAppBar works? It works because when we assigned extendBodyBehindAppBar as true, then the body of the widget takes the height of AppBar, and we see an image covering the AppBar area.

    Simple Example:

    Size size = MediaQuery.of(context).size;
        return Scaffold(
          extendBodyBehindAppBar: true,
          body: Container(
            // height: size.height * 0.3,
            child: Image.asset(
              'shopping_assets/images/Fruits/pineapple.png',
              fit: BoxFit.cover,
              height: size.height * 0.4,
              width: size.width,
            ),
          ),
        );
    

提交回复
热议问题