Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions case_study/memory_leaks/images_1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@ A material design widget to view downloaded network images.
**Solution:** Fix the ListView.builder add the parameters cacheHeight and cacheWidth to the Image.network constructor e.g.,

Look for:
```dart
```
Widget listView() => ListView.builder
```

Find the Image.network constructor then add the below parameters:

```dart
```
// Decode image to a specified height and width (ResizeImage).
cacheHeight: 1024,
cacheWidth: 1024,
```
Original code:

```dart
```
final image = Image.network(
imgUrl,
width: 750.0,
Expand All @@ -40,7 +40,7 @@ A material design widget to view downloaded network images.

Fixed code:

```dart
```
final image = Image.network(
imgUrl,
width: 750.0,
Expand All @@ -63,7 +63,7 @@ A material design widget to view downloaded network images.

The parameters cacheWidth or cacheHeight indicates to the engine that the image should be decoded at the specified size e.g., thumbnail. If not specified the full image will be used each time when all that is needed is a much smaller image. The image will be rendered to the constraints of the layout or width and height regardless of these parameters. These parameters are intended to reduce the memory usage of ImageCache

Read [[Documentation](https://api.flutter.dev/flutter/widgets/Image/Image.network.html)].
Read [[Image.network Documentation](https://api.flutter.dev/flutter/widgets/Image/Image.network.html)].

<img src="demo_img.gif" height="600em" />

Expand Down