'How to decode image with widget size in AspectRatio widget?
I am using AspectRatio widget to size images in my app. Here's the code:
Widget _buildThumbnail() {
return AspectRatio(
aspectRatio: 1,
child: CachedNetworkImage(
imageUrl: artist.thumbnail,
fit: BoxFit.cover,
),
);
}
Images are large, and I want to use image-widget size as image decode size. I do not know what the image-widget size is before hand. This widget is loaded in a GridView with crossAxisCount of 2, 3, and sometimes 4.
Is there a way to tell cached_network_image or Image widget to auto decode image according to widget size? Or a way to get size of AspectRatio's child?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
