Repository: flutter
Issue: [flutter_svg]  Error: 'AssetBundle' isn't a type.     AssetBundle? bundle,
Labels: package,p: flutter_svg

_Imported from https://github.com/dnfield/flutter_svg/issues/610_

Original report by @abhilash007 on Oct 19, 2021

../../flutter/.pub-cache/hosted/pub.dartlang.org/flutter_svg-0.23.0+1/lib/svg.dart:325:5: Error: 'AssetBundle' isn't a type.
    AssetBundle? bundle,

---
Comment by @daohoangson on Oct 19, 2021
If you are on stable channel, make sure Flutter version is at least `2.5.0`. You need at least 2.4.0 pre for the latest version of this package. See #611.

---
Comment by @AramSemerjyan on Nov 1, 2021
Same for me. Haven't tried it on android yet. But getting error:

```
../../flutter/.pub-cache/hosted/pub.dartlang.org/flutter_svg-0.23.0+1/lib/svg.dart:325:5: Error: Type 'AssetBundle' not found.
        AssetBundle? bundle,
        ^^^^^^^^^^^
    ../../flutter/.pub-cache/hosted/pub.dartlang.org/flutter_svg-0.23.0+1/lib/svg.dart:325:5: Error: 'AssetBundle' isn't a type.
        AssetBundle? bundle
```

when building on iOS.

Here is my `flutter doctor -v` result:

```
[✓] Flutter (Channel stable, 2.5.3, on macOS 11.6 20G165 darwin-x64, locale en-US)
    • Flutter version 2.5.3 at /Users/aram/Documents/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 18116933e7 (2 weeks ago), 2021-10-15 10:46:35 -0700
    • Engine revision d3ea636dc5
    • Dart version 2.14.4

[!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /Users/aram/Library/Android/sdk
    ✗ cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 13.0, Build version 13A233
    • CocoaPods version 1.11.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.1)
    • 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 1.8.0_242-release-1644-b3-6915495)

[✓] VS Code (version 1.56.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension can be installed from:
      🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (3 available)
    • sdk gphone x86 arm (mobile) • emulator-5554                        • android-x86    • Android 11 (API 30) (emulator)
    • iPhone 12 Pro Max (mobile)  • 41C5B2F0-9B55-49DC-BC3A-13881C97AEE2 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-15-0 (simulator)
    • Chrome (web)                • chrome                               • web-javascript • Google Chrome 95.0.4638.54

! Doctor found issues in 1 category.
```

---
Comment by @anglesen1120 on Nov 4, 2021
> Same for me. Haven't tried it on android yet. But getting error:
> 
> ```
> ../../flutter/.pub-cache/hosted/pub.dartlang.org/flutter_svg-0.23.0+1/lib/svg.dart:325:5: Error: Type 'AssetBundle' not found.
>         AssetBundle? bundle,
>         ^^^^^^^^^^^
>     ../../flutter/.pub-cache/hosted/pub.dartlang.org/flutter_svg-0.23.0+1/lib/svg.dart:325:5: Error: 'AssetBundle' isn't a type.
>         AssetBundle? bundle
> ```
> 
> when building on iOS.
> 
> Here is my `flutter doctor -v` result:
> 
> ```
> [✓] Flutter (Channel stable, 2.5.3, on macOS 11.6 20G165 darwin-x64, locale en-US)
>     • Flutter version 2.5.3 at /Users/aram/Documents/flutter
>     • Upstream repository https://github.com/flutter/flutter.git
>     • Framework revision 18116933e7 (2 weeks ago), 2021-10-15 10:46:35 -0700
>     • Engine revision d3ea636dc5
>     • Dart version 2.14.4
> 
> [!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
>     • Android SDK at /Users/aram/Library/Android/sdk
>     ✗ cmdline-tools component is missing
>       Run `path/to/sdkmanager --install "cmdline-tools;latest"`
>       See https://developer.android.com/studio/command-line for more details.
>     ✗ Android license status unknown.
>       Run `flutter doctor --android-licenses` to accept the SDK licenses.
>       See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.
> 
> [✓] Xcode - develop for iOS and macOS
>     • Xcode at /Applications/Xcode.app/Contents/Developer
>     • Xcode 13.0, Build version 13A233
>     • CocoaPods version 1.11.2
> 
> [✓] Chrome - develop for the web
>     • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
> 
> [✓] Android Studio (version 4.1)
>     • 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 1.8.0_242-release-1644-b3-6915495)
> 
> [✓] VS Code (version 1.56.2)
>     • VS Code at /Applications/Visual Studio Code.app/Contents
>     • Flutter extension can be installed from:
>       🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
> 
> [✓] Connected device (3 available)
>     • sdk gphone x86 arm (mobile) • emulator-5554                        • android-x86    • Android 11 (API 30) (emulator)
>     • iPhone 12 Pro Max (mobile)  • 41C5B2F0-9B55-49DC-BC3A-13881C97AEE2 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-15-0 (simulator)
>     • Chrome (web)                • chrome                               • web-javascript • Google Chrome 95.0.4638.54
> 
> ! Doctor found issues in 1 category.
> ```

You should be try again with flutter 2.5.3! clean and run again ^^

---
Comment by @pdsliuzhen on Nov 8, 2021
Same for me

---
Comment by @cristian1980 on Nov 10, 2021
I had the same issue but, upgrading to 2.5.3 and restarting Android Studio, fixed it.

---
Comment by @pdsliuzhen on Nov 15, 2021
my flutter version is 2.2.3 is not ok, upgrade to 2.5 is ok, but i have to use verison 2.2.3

---
Comment by @baguskto on Nov 20, 2021
I use flutter version 2.2.2, and use flutter_svg version 0.22.0. its works like a charm

---
Comment by @nizarmasri-rockspoon on Dec 7, 2021
Running on Flutter 2.5.3 stable, cleaned the project and restarted android studio, still getting this error

---
Comment by @kannel-outis on Dec 7, 2021
is there any fix for this without upgrading flutter.... the latest flutter version keeps deleting my .gradle folder so it is not an option for me ATM .

---
Comment by @shinayser on Jan 19, 2022
I'm having this project right now. Using flutter 2.2.3 and can't upgrade it to 2.8 (or 2.5) yet =(

And I dont have direct dependnecy of flutter_svg, it is coming as a transitive dependency from the `flutter_html` package.


---
Comment by @dnfield on Jan 19, 2022
Ahh so it sounds like I missed updating a lower bound constraint on the package. That's unfortunate. I don't have a great way to fix that. If you're seeing this issue, you need to either upgrade your flutter SDK or downgrade your flutter_svg...

---
Comment by @shinayser on Jan 20, 2022
I was able to fix that by placing:

```
dependency_overrides:
  flutter_svg: 0.22.0
```
on my apps's `pubpec.yaml`.

---
Comment by @moradnajem on Feb 25, 2022
+1