Repository: flutter
Issue: PaintingBinding.instance.imageCache.maximumSizeBytes not working 
Labels: platform-ios,framework,a: images,perf: memory,has reproducible steps,P2,found in release: 3.3,found in release: 3.4,team-ios,triaged-ios

## Steps to Reproduce

The title is actually wrong : the setter is working (i have logged it) but the actions that should `evict` and release images from memory after setting the value are not working.

1. Run the sample app 
2. Open dev tools on the memory tab and note the current memory usage value
3. Click on the `start` button
4. See the memory increase 
5. Go back to the main page and note the memory usage

**Expected results:** <!-- what did you want to see? -->

In previous version of Flutter ( < `3.0.x`), when using `PaintingBinding.instance.imageCache.maximumSizeBytes = 1024 * 1024 * 30` it would evict any images from memory cache to maintain the cap at 30MB of memory usage. 

In this example, the memory usage of step 5 should be equal at step 2 ideally. But if for any reason it would not be the case, the memory of step 5 should NOT be higher than `memory_step2_value + 30MB` thanks to the `PaintingBinding.instance.imageCache.maximumSizeBytes` setter.

**Actual results:** <!-- what did you see? -->

The memory usage is much higher.

In my case it's + 140MB : 

![Capture d’écran 2022-09-02 à 13 03 21](https://user-images.githubusercontent.com/32631467/188126175-85f39298-5885-44d3-8ab1-ad65c5f09290.png)

Against 30MB initially : 

![Capture d’écran 2022-09-02 à 13 04 20](https://user-images.githubusercontent.com/32631467/188126297-0a446e88-ae96-4d12-90e6-dc2c1da6e445.png)

This is a real issue because this was my workaround to counter #102140  and #62107 and it's not working anymore.  
The real issue is the above one because images are not released from memory or at least in a very bad / long way.

<details>
<summary>Code sample</summary>


```dart
import 'package:flutter/material.dart';

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  PaintingBinding.instance.imageCache.maximumSizeBytes = 1024 * 1024 * 30;
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) => const MaterialApp(home: Home());
}

class Home extends StatelessWidget {
  const Home({Key? key}) : super(key: key);

  Future<void> openGallery(BuildContext context) {
    return Navigator.of(context).push(MaterialPageRoute(builder: (_) => Gallery()));
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: ElevatedButton(
          child: const Text("Start"),
          onPressed: () => openGallery(context),
        ),
      ),
    );
  }
}

class Gallery extends StatelessWidget {
  final String imageURL = 'https://picsum.photos/1500?image=';
  final int maxImageID = 75;
  final int columns = 2;
  final ScrollController controller = ScrollController();

  Gallery({Key? key}) : super(key: key);

  void animateToOffset(double offset) {
    if (offset > controller.offset) {
      Future.delayed(const Duration(seconds: 1)).then((_) {
        controller.animateTo(
          offset,
          duration: const Duration(seconds: 1),
          curve: Curves.easeInOut,
        );
      });
    }
  }

  @override
  Widget build(BuildContext context) {
    double imageSize = MediaQuery.of(context).size.width / columns;

    return Scaffold(
      appBar: AppBar(title: const Text("Gallery")),
      body: GridView.builder(
        controller: controller,
        gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: columns),
        itemBuilder: (context, index) {
          return Image.network(
            "$imageURL${index % maxImageID}",
            fit: BoxFit.cover,
            height: imageSize,
            width: imageSize,
            frameBuilder: (context, child, frame, _) {
              if (frame == null) return child;
              animateToOffset(imageSize * (index ~/ columns));
              return child;
            },
          );
        },
      ),
    );
  }
}
```

</details>

<details>
  <summary>Logs</summary>

<!-- Finally, paste the output of running `flutter doctor -v` here. -->

```
[✓] Flutter (Channel stable, 3.3.0, on macOS 12.5.1 21G83 darwin-x64, locale fr-FR)
    • Flutter version 3.3.0 on channel stable at /Users/foxtom/Desktop/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision ffccd96b62 (3 days ago), 2022-08-29 17:28:57 -0700
    • Engine revision 5e9e0e0aa8
    • Dart version 2.18.0
    • DevTools version 2.15.0

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Android SDK at /Users/foxtom/Library/Android/sdk
    • Platform android-33, build-tools 33.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.4.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 13F100
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)

[✓] VS Code (version 1.70.2)
    • VS Code at /Users/foxtom/Desktop/Visual Studio Code.app/Contents
    • Flutter extension version 3.46.0

[✓] Connected device (3 available)
    • Now You See Me (mobile) • 00008020-001204401E78002E • ios            • iOS 15.6.1 19G82
    • macOS (desktop)         • macos                     • darwin-x64     • macOS 12.5.1 21G83 darwin-x64
    • Chrome (web)            • chrome                    • web-javascript • Google Chrome 104.0.5112.101

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!
```

</details>