Repository: flutter
Issue: An image loading error is reported even when it is handled by the application
Labels: framework,a: images,a: error message,has reproducible steps,P2,found in release: 3.10,found in release: 3.12,team-framework,triaged-framework

### Is there an existing issue for this?

- [X] I have searched the [existing issues](https://github.com/flutter/flutter/issues)
- [X] I have read the [guide to filing a bug](https://flutter.dev/docs/resources/bug-reports)

### Steps to reproduce

1. Launch the app on Android or other device where Hot reload is enabled
2. Wait for the image to fail loading
3. Push a new route
4. Perform a hot reload and observe an image error in logs which wasn't there before

### Expected results

There should be not errors reported about the image failing to load on the second page just like there isn't on the first.

### Actual results

An error is issued when there should be not error since this page does not contain the image and the previous one handles it.

### Code sample

<details><summary>Code sample</summary>

```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(routes: {
      Navigator.defaultRouteName: (_) => const _PageA(),
      '/b': (_) => const _PageB(),
    });
  }
}

class _PageA extends StatelessWidget {
  const _PageA();

  @override
  Widget build(BuildContext context) {
    return _ContentScaffold(children: [
      Image.network(
          'https://example.com/some-non-existing-resource-12def223d23422ef213dfef.jpg',
          errorBuilder: (context, error, stacktrace) {
        return const Text(
          'Non existant image requested! No error in console, as expected. Not even if we trigger hot reload.',
        );
      }, frameBuilder: (context, child, frame, wasSynchronous) {
        if (frame == 0) return const Text('Loading image, please wait');

        return child;
      }),
      TextButton(
        child: const Text('Go to B'),
        onPressed: () => Navigator.of(context).pushNamed('/b'),
      ),
    ]);
  }
}

class _PageB extends StatelessWidget {
  const _PageB();

  @override
  Widget build(BuildContext context) {
    return _ContentScaffold(children: [
      const Text(
        'Observe an error in console or trigger hot reload and observe it then.',
        textAlign: TextAlign.center,
      ),
      TextButton(
        child: const Text('Back to home'),
        onPressed: () {
          Navigator.of(context)
              .popUntil(ModalRoute.withName(Navigator.defaultRouteName));
        },
      )
    ]);
  }
}

class _ContentScaffold extends StatelessWidget {
  final List<Widget> children;

  const _ContentScaffold({required this.children});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Padding(
        padding: const EdgeInsets.symmetric(horizontal: 50),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.stretch,
          children: children,
        ),
      ),
    );
  }
}
```

</details>


### Screenshots or Video

_No response_

### Logs

_No response_

### Flutter Doctor output

<details><summary>Doctor output</summary>

```console
[✓] Flutter (Channel stable, 3.10.5, on macOS 11.7.8 20G1351 darwin-x64, locale en-GB)
    • Flutter version 3.10.5 on channel stable at /usr/local/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 796c8ef792 (3 weeks ago), 2023-06-13 15:51:02 -0700
    • Engine revision 45f6e00911
    • Dart version 3.0.5
    • DevTools version 2.23.1

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Android SDK at /Users/jellynoone/Library/Android/sdk
    • Platform android-33, build-tools 33.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
    • All Android licenses accepted.

[!] Xcode - develop for iOS and macOS (Xcode 13.2.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 13C100
    ✗ CocoaPods not installed.
        CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to your plugin usage on the Dart side.
        Without CocoaPods, plugins will not work on iOS or macOS.
        For more info, see https://flutter.dev/platform-plugins
      To install see https://guides.cocoapods.org/using/getting-started.html#installation for instructions.

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.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 17.0.6+0-17.0.6b802.4-9586694)

[✓] VS Code (version 1.80.0-insider)
    • VS Code at /Applications/Visual Studio Code - Insiders.app/Contents
    • Flutter extension version 3.68.0

[✓] Connected device (3 available)
    • Pixel (mobile)  • FA76R0301797 • android-arm64  • Android 10 (API 29)
    • macOS (desktop) • macos        • darwin-x64     • macOS 11.7.8 20G1351 darwin-x64
    • Chrome (web)    • chrome       • web-javascript • Google Chrome 114.0.5735.198

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 1 category.
```

</details>