Baseflow / Baseflow/flutter_cached_network_image

CachedNetworkImageProvider does not work together with ResizeImage and ResizeImagePolicy.fit

Open
#847 1 comment 7 reactions 0 assignees View on GitHub
Dominant language
Dart
Stars
2.6k
Forks
731
Avg merge
3d 9h
Merged PRs (30d)
1

Description

## 🐛 Bug Report

Flutter recently added a `policy` parameter to `ResizeImage`, where one of the enum values is `ResizeImagePolicy.fit`. Basically, it is used to be able to resize an image while retaining the aspect ratio (See here for more context: https://github.com/flutter/flutter/issues/118543). This does not work together with CachedNetworkImageProvider. The image will be squished to fit into the width and height no matter the value of `width` and `height`. See below:

![Imgur](https://imgur.com/elmSuZz.png)

### Expected behavior

It should look like `NetworkImage`:

![Imgur](https://imgur.com/AvLBiAo.png)

### Reproduction steps

* Create a new Flutter project
* Replace the content of `main.dart` with:
```
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';

void main() {
runApp(const MainApp());
}

class MainApp extends StatelessWidget {
const MainApp({super.key});

@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Container(
color: Colors.red,
width: 300,
height: 300,
child: const Image(
image: ResizeImage(
CachedNetworkImageProvider('https://placekitten.com/500/1000'),
width: 300,
height: 300,
policy: ResizeImagePolicy.fit,
),
),
),
),
);
}
}
```
* See squished cat

### Configuration

**Version:** 3.2.3
**Flutter version:** 3.10.2

**Platform:**
- [ ] :iphone: iOS
- [x] :robot: Android

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.