FadeInImage in BoxDecoration

前端 未结 3 619
长情又很酷
长情又很酷 2021-01-25 11:28

I love the FadeInImage

I can do this

child: FadeInImage.assetNetwork(
    image: \'https://placeimg.com/640/480/any\',
    placeholder: \'assets/images/l         


        
3条回答
  •  盖世英雄少女心
    2021-01-25 12:09

    I achieved something similar. This image is a hero image at the top of the page, hence the height. The combination of width and BoxFit.cover make the image cover the viewport. The loader is (visually) hidden when the image loads.

    final imageWithLoader = Container(
        height: MediaQuery.of(context).size.height * 0.5,
        child: Stack(children: [
          Center(child: CircularProgressIndicator()),
          Center(
            child: FadeInImage.memoryNetwork(
                placeholder: kTransparentImage,
                image: library.url,
                width: MediaQuery.of(context).size.width,
                fit: BoxFit.cover),
          ),
        ]));
    

提交回复
热议问题