Repository: flutter
Issue: Unable to catch NetworkImageLoadException exception
Labels: framework,a: images,a: error message,has reproducible steps,P2,found in release: 3.3,found in release: 3.7,team-framework,triaged-framework

## Steps to Reproduce

1. Add AssetImage.png into lib folder
1. Build and run the app for iOS
2. After app will launch you will see blank page

**Expected results:** 
White Image with Asset Image text on it 

**Actual results:**
White page without image

<details>
<summary>Code sample</summary>

```dart
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key, required this.title}) : super(key: key);

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Container(
              width: 300,
              height: 300,
              decoration: BoxDecoration(
                shape: BoxShape.rectangle,
                image: DecorationImage(
                    image: imageTest(
                      // 'https://www.muddymatches.co.uk/data/photos/mobile/11347efed27430cabacdb73c6731aa9e_1673885453.jpg', //Correct image
                      'https://www.muddymatches.co.uk/data/photos/mobile/11347efed274cabacdb73c6731aa9e_1673885453.jpg', //Incorrect image, try catch should be used
                    ),
                    fit: BoxFit.cover),
              ),
            ),
          ],
        ),
      ),
    );
  }
}

ImageProvider imageTest(String url) {
  try {
    return NetworkImage(url);
  } catch (e) {
    return const AssetImage('lib/AssetImage.png');
  }
}

```

</details>

Exception I'm unable to catch:
```
══╡ EXCEPTION CAUGHT BY IMAGE RESOURCE SERVICE ╞════════════════════════════════════════════════════
           The following NetworkImageLoadException was thrown resolving an image codec:
           HTTP request failed, statusCode: 403,
           https://www.muddymatches.co.uk/data/photos/mobile/11347efed274cabacdb73c6731aa9e_1673885453.jpg

           When the exception was thrown, this was the stack:
           #0      NetworkImage._loadAsync (package:flutter/src/painting/_network_image_io.dart:97:9)
           <asynchronous suspension>

           Image provider:
             NetworkImage("https://www.muddymatches.co.uk/data/photos/mobile/11347efed274cabacdb73c6731aa9e_1673885453.jpg",
             scale: 1.0)
           Image key:
             NetworkImage("https://www.muddymatches.co.uk/data/photos/mobile/11347efed274cabacdb73c6731aa9e_1673885453.jpg",
             scale: 1.0)
           ════════════════════════════════════════════════════════════════════════════════════════════════════
```

<details>
  <summary>Logs</summary>

Flutter run --verbose
Had to limit it, it was to long and I was unable to submit the issue.

```
[   +2 ms] executing: rsync -8 -av --delete /Users/lukaszconer/Development/flutter_test_app/build/ios/Debug-iphonesimulator/Runner.app /Users/lukaszconer/Development/flutter_test_app/build/ios/iphonesimulator
[ +163 ms] building file list ... done
           Runner.app/
           Runner.app/Info.plist
           Runner.app/PkgInfo
           Runner.app/Runner
           Runner.app/Frameworks/App.framework/
           Runner.app/Frameworks/App.framework/App
           Runner.app/Frameworks/App.framework/_CodeSignature/CodeResources
           Runner.app/Frameworks/App.framework/flutter_assets/AssetManifest.json
           Runner.app/Frameworks/App.framework/flutter_assets/FontManifest.json
           Runner.app/Frameworks/App.framework/flutter_assets/NOTICES.Z
           Runner.app/Frameworks/App.framework/flutter_assets/kernel_blob.bin
           Runner.app/_CodeSignature/CodeResources

           sent 39555283 bytes  received 252 bytes  79111070.00 bytes/sec
           total size is 88834857  speedup is 2.25
[   +1 ms] executing: /usr/bin/arch -arm64e xcrun simctl install 615251AB-C965-49B4-B887-A67EA2F43317 /Users/lukaszconer/Development/flutter_test_app/build/ios/iphonesimulator/Runner.app
[ +352 ms] executing: /usr/bin/plutil -convert xml1 -o - /Users/lukaszconer/Development/flutter_test_app/build/ios/iphonesimulator/Runner.app/Info.plist
[   +4 ms] Exit code 0 from: /usr/bin/plutil -convert xml1 -o - /Users/lukaszconer/Development/flutter_test_app/build/ios/iphonesimulator/Runner.app/Info.plist
[        ] <?xml version="1.0" encoding="UTF-8"?>
           <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
           <plist version="1.0">
           <dict>
           	<key>BuildMachineOSBuild</key>
           	<string>22A400</string>
           	<key>CADisableMinimumFrameDurationOnPhone</key>
           	<true/>
           	<key>CFBundleDevelopmentRegion</key>
           	<string>en</string>
           	<key>CFBundleExecutable</key>
           	<string>Runner</string>
           	<key>CFBundleIcons</key>
           	<dict>
           		<key>CFBundlePrimaryIcon</key>
           		<dict>
           			<key>CFBundleIconFiles</key>
           			<array>
           				<string>AppIcon60x60</string>
           			</array>
           			<key>CFBundleIconName</key>
           			<string>AppIcon</string>
           		</dict>
           	</dict>
           	<key>CFBundleIcons~ipad</key>
           	<dict>
           		<key>CFBundlePrimaryIcon</key>
           		<dict>
           			<key>CFBundleIconFiles</key>
           			<array>
           				<string>AppIcon60x60</string>
           				<string>AppIcon76x76</string>
           			</array>
           			<key>CFBundleIconName</key>
           			<string>AppIcon</string>
           		</dict>
           	</dict>
           	<key>CFBundleIdentifier</key>
           	<string>com.example.flutterTestApp</string>
           	<key>CFBundleInfoDictionaryVersion</key>
           	<string>6.0</string>
           	<key>CFBundleName</key>
           	<string>flutter_test_app</string>
           	<key>CFBundlePackageType</key>
           	<string>APPL</string>
           	<key>CFBundleShortVersionString</key>
           	<string>1.0.0</string>
           	<key>CFBundleSignature</key>
           	<string>????</string>
           	<key>CFBundleSupportedPlatforms</key>
           	<array>
           		<string>iPhoneSimulator</string>
           	</array>
           	<key>CFBundleVersion</key>
           	<string>1</string>
           	<key>DTCompiler</key>
           	<string>com.apple.compilers.llvm.clang.1_0</string>
           	<key>DTPlatformBuild</key>
           	<string>20C52</string>
           	<key>DTPlatformName</key>
           	<string>iphonesimulator</string>
           	<key>DTPlatformVersion</key>
           	<string>16.2</string>
           	<key>DTSDKBuild</key>
           	<string>20C52</string>
           	<key>DTSDKName</key>
           	<string>iphonesimulator16.2</string>
           	<key>DTXcode</key>
           	<string>1420</string>
           	<key>DTXcodeBuild</key>
           	<string>14C18</string>
           	<key>LSRequiresIPhoneOS</key>
           	<true/>
           	<key>MinimumOSVersion</key>
           	<string>11.0</string>
           	<key>UIDeviceFamily</key>
           	<array>
           		<integer>1</integer>
           		<integer>2</integer>
           	</array>
           	<key>UILaunchStoryboardName</key>
           	<string>LaunchScreen</string>
           	<key>UIMainStoryboardFile</key>
           	<string>Main</string>
           	<key>UISupportedInterfaceOrientations</key>
           	<array>
           		<string>UIInterfaceOrientationPortrait</string>
           		<string>UIInterfaceOrientationLandscapeLeft</string>
           		<string>UIInterfaceOrientationLandscapeRight</string>
           	</array>
           	<key>UISupportedInterfaceOrientations~ipad</key>
           	<array>
           		<string>UIInterfaceOrientationPortrait</string>
           		<string>UIInterfaceOrientationPortraitUpsideDown</string>
           		<string>UIInterfaceOrientationLandscapeLeft</string>
           		<string>UIInterfaceOrientationLandscapeRight</string>
           	</array>
           	<key>UIViewControllerBasedStatusBarAppearance</key>
           	<false/>
           </dict>
           </plist>
[   +3 ms] executing: /usr/bin/arch -arm64e xcrun simctl launch 615251AB-C965-49B4-B887-A67EA2F43317 com.example.flutterTestApp --enable-dart-profiling --enable-checked-mode --verify-entry-points --observatory-port=0
[ +116 ms] com.example.flutterTestApp: 87847
[        ] Waiting for observatory port to be available...
[+2933 ms] Observatory URL on device: http://127.0.0.1:56892/QBsdff0Qmnk=/
[   +3 ms] Caching compiled dill
[  +60 ms] Connecting to service protocol: http://127.0.0.1:56892/QBsdff0Qmnk=/
[  +58 ms] Launching a Dart Developer Service (DDS) instance at http://127.0.0.1:0, connecting to VM service at http://127.0.0.1:56892/QBsdff0Qmnk=/.
[  +76 ms] DDS is listening at http://127.0.0.1:56897/xCRmij174lw=/.
[  +26 ms] Successfully connected to service protocol: http://127.0.0.1:56892/QBsdff0Qmnk=/
[  +12 ms] DevFS: Creating new filesystem on the device (null)
[   +7 ms] DevFS: Created new filesystem on the device (file:///Users/lukaszconer/Library/Developer/CoreSimulator/Devices/615251AB-C965-49B4-B887-A67EA2F43317/data/Containers/Data/Application/E2025FDE-0C60-4B42-9E5B-6A380A92B6CA/tmp/flutter_test_appsCCBih/flutter_test_app/)
[   +1 ms] Updating assets
[  +34 ms] Syncing files to device iPhone 12 Pro Max...
[        ] <- reset
[        ] Compiling dart to kernel with 0 updated files
[        ] Processing bundle.
[        ] <- recompile package:flutter_test_app/main.dart 12a420db-035c-4e82-b86b-c67905f4ab3b
[        ] <- 12a420db-035c-4e82-b86b-c67905f4ab3b
[        ] Bundle processing done.
[  +30 ms] Updating files.
[        ] DevFS: Sync finished
[        ] Syncing files to device iPhone 12 Pro Max... (completed in 32ms)
[        ] Synced 0.0MB.
[        ] <- accept
[   +2 ms] Connected to _flutterView/0x129035820.
[   +1 ms] Flutter run key commands.
[        ] r Hot reload. 🔥🔥🔥
[        ] R Hot restart.
[        ] h List all available interactive commands.
[        ] d Detach (terminate "flutter run" but leave application running).
[        ] c Clear the screen
[        ] q Quit (terminate the application on the device).
[        ] 💪 Running with sound null safety 💪
[        ] An Observatory debugger and profiler on iPhone 12 Pro Max is available at: http://127.0.0.1:56897/xCRmij174lw=/
[ +189 ms] The Flutter DevTools debugger and profiler on iPhone 12 Pro Max is available at: http://127.0.0.1:9101?uri=http://127.0.0.1:56897/xCRmij174lw=/
[ +242 ms] 
           ══╡ EXCEPTION CAUGHT BY IMAGE RESOURCE SERVICE ╞════════════════════════════════════════════════════
           The following NetworkImageLoadException was thrown resolving an image codec:
           HTTP request failed, statusCode: 403,
           https://www.muddymatches.co.uk/data/photos/mobile/11347efed274cabacdb73c6731aa9e_1673885453.jpg

           When the exception was thrown, this was the stack:
           #0      NetworkImage._loadAsync (package:flutter/src/painting/_network_image_io.dart:97:9)
           <asynchronous suspension>

           Image provider:
             NetworkImage("https://www.muddymatches.co.uk/data/photos/mobile/11347efed274cabacdb73c6731aa9e_1673885453.jpg",
             scale: 1.0)
           Image key:
             NetworkImage("https://www.muddymatches.co.uk/data/photos/mobile/11347efed274cabacdb73c6731aa9e_1673885453.jpg",
             scale: 1.0)
           
[+82182 ms] Application finished.
```

flutter analyze:

```
Analyzing flutter_test_app...                                           
No issues found! (ran in 1.0s)
```

<!-- Finally, paste the output of running `flutter doctor -v` here. -->
flutter doctor -v

```
[✓] Flutter (Channel stable, 3.0.5, on macOS 13.0.1 22A400 darwin-arm, locale en-GB)
    • Flutter version 3.0.5 at /Users/lukaszconer/Development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision f1875d570e (6 months ago), 2022-07-13 11:24:16 -0700
    • Engine revision e85ea0e79c
    • Dart version 2.17.6
    • DevTools version 2.12.2

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/lukaszconer/Library/Android/sdk
    • Platform android-31, build-tools 31.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 14.2)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • 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.74.3)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.56.0

[✓] Connected device (3 available)
    • iPhone 12 Pro Max (mobile) • 615251AB-C965-49B4-B887-A67EA2F43317 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-15-0 (simulator)
    • macOS (desktop)            • macos                                • darwin-arm64   • macOS 13.0.1 22A400 darwin-arm
    • Chrome (web)               • chrome                               • web-javascript • Google Chrome 108.0.5359.124

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

```

flutter versions

```
Flutter 3.0.5 • channel stable • https://github.com/flutter/flutter.git
Framework • revision f1875d570e (6 months ago) • 2022-07-13 11:24:16 -0700
Engine • revision e85ea0e79c
Tools • Dart 2.17.6 • DevTools 2.12.2
```
</details>

AssetImage.png file which should be displayed when NetworkImage unable to load a file:
![AssetImage](https://user-images.githubusercontent.com/1197895/212774911-e033523b-5a89-4ce0-8b04-532d56a5e449.png)

App and photo I expect to see:
![Simulator Screen Shot - iPhone 12 Pro Max - 2023-01-16 at 22 39 24](https://user-images.githubusercontent.com/1197895/212775549-8ae64790-f5d4-4441-98e2-c9b50e631158.png)