1

In this scenario I can not make to work the fit property with BoxFit.cover. There is always borders on screen. How can I do it?

Scaffold(
  appBar: AppBar(),
  body: CachedNetworkImage(
    height: double.infinity,
    width: double.infinity,
    fit: BoxFit.cover, // does not work
    imageUrl: _imageUrl,
    imageBuilder: (context, imageProvider) => PhotoView(
      imageProvider: imageProvider,
    ),
  ),
);
onlit
  • 728
  • 5
  • 19
rozerro
  • 5,787
  • 9
  • 46
  • 94

3 Answers3

0
       Container(
        child: CachedNetworkImage(
          imageUrl: _imageUrl,
          imageBuilder: (context, imageProvider)=>PhotoView(
            minScale: 1.0,
            imageProvider: imageProvider,
          ),
        ),
      ),
0

For the future searchers, there is an another solution which seems perfectly fits the desired behaviour. https://stackoverflow.com/a/58200356/5829191

rozerro
  • 5,787
  • 9
  • 46
  • 94
0

This work for me. Since I have a Container with the same borderRadius as the Catched Image. Without the BoxDecoration it failed med too!

    Container( decoration: BoxDecoration(borderRadius: 
BorderRadius.circular(10),),child:CachedNetworkImage(imageUrl: ("UrlToImage"),imageBuilder: (context, imageProvider) => Container(decoration: BoxDecoration(borderRadius: BorderRadius.circular(10),image: DecorationImage(image: imageProvider,
                                            fit: BoxFit.cover,
                                            )),),placeholder: (context, url) => CircularProgressIndicator(),errorWidget: (context, url, error) => Image.asset("PathToImage")
                                  ),
PasPro
  • 55
  • 8