Flutter_cached_network_image: fit: Boxfit not working as expected (not working unless height/width is set)

Created on 27 Feb 2019  路  8Comments  路  Source: Baseflow/flutter_cached_network_image

fit: Boxfit.cover not working for image in lastest update

Most helpful comment

It should work if you set height and/or width. Otherwise it just takes the size it needs for the image. If you set height and width to double.INFINITY it should work as previously. I'll update the documentation for that. If it doesn't please re-open this issue.

All 8 comments

It should work if you set height and/or width. Otherwise it just takes the size it needs for the image. If you set height and width to double.INFINITY it should work as previously. I'll update the documentation for that. If it doesn't please re-open this issue.

I'll reopen this, as it is no expected behaviour.

So, setting the height and width to double.INFINITY is the final solution, or is this going to be fixed?

Fixed in 0.7.0

Using latest, same behaviour seems to be present.

still present in 1.12 but fixed with @jesusrp98 suggestion

Using DecorationImage I could make it work:

class Default extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Container(
      decoration: BoxDecoration(
        image: DecorationImage(
            image: AssetImage('../image.jpg'),
            fit: BoxFit.cover),
      ),
    );
  }
}

still present in 1.20 but fixed with @renefloor suggestion

Was this page helpful?
0 / 5 - 0 ratings