Assets in package, app e web

533 views
Skip to first unread message

Leonardo Ferreira

unread,
Nov 2, 2019, 10:37:50 PM11/2/19
to Flutter Development (flutter-dev)
Hello friends, I have a problem when I try to make use of assets within my project which is a package containing 3 more projects.

When running the project project_app, and accessing images that are in project / assets / images, the error below


Running "flutter pub get" in atae_zeus_app...                       1,2s
Launching lib\main.dart on Android SDK built for x86 in debug mode...
Running Gradle task 'assembleDebug'...
√ Built build\app\outputs\apk\debug\app-debug.apk.
Syncing files to device Android SDK built for x86...
D/EGL_emulation(30071): eglMakeCurrent: 0xa79054e0: ver 2 0 (tinfo 0xa7903840)
I/flutter (30071): ══╡ EXCEPTION CAUGHT BY IMAGE RESOURCE SERVICE ╞════════════════════════════════════════════════════
I/flutter (30071): The following assertion was thrown resolving an image codec:
I/flutter (30071): Unable to load asset: assets/images/splash.png
I/flutter (30071): 
I/flutter (30071): When the exception was thrown, this was the stack:
I/flutter (30071): #0      PlatformAssetBundle.load (package:flutter/src/services/asset_bundle.dart:221:7)
I/flutter (30071): <asynchronous suspension>
I/flutter (30071): #1      AssetBundleImageProvider._loadAsync (package:flutter/src/painting/image_provider.dart:484:44)
I/flutter (30071): <asynchronous suspension>
I/flutter (30071): #2      AssetBundleImageProvider.load (package:flutter/src/painting/image_provider.dart:469:14)
I/flutter (30071): #3      ImageProvider.resolve.<anonymous closure>.<anonymous closure>.<anonymous closure> (package:flutter/src/painting/image_provider.dart:327:17)
I/flutter (30071): #4      ImageCache.putIfAbsent (package:flutter/src/painting/image_cache.dart:160:22)
I/flutter (30071): #5      ImageProvider.resolve.<anonymous closure>.<anonymous closure> (package:flutter/src/painting/image_provider.dart:325:84)
I/flutter (30071): (elided 13 frames from package dart:async)
I/flutter (30071): 
I/flutter (30071): Image provider: AssetImage(bundle: null, name: "assets/images/splash.png")
I/flutter (30071): Image key: AssetBundleImageKey(bundle: PlatformAssetBundle#88b21(), name:
I/flutter (30071):   "assets/images/splash.png", scale: 1.0)
I/flutter (30071): ════════════════════════════════════════════════════════════════════════════════════════════════════
I/flutter (30071): Another exception was thrown: Unable to load asset: assets/images/logo_a_round.png
atae_zeus [DWorkspaceFlutteratae_zeus] - ...atae_zeuspubspec.yaml [atae_zeus] - Android Studio.jpg
atae_zeus [DWorkspaceFlutteratae_zeus] - Android Studio.jpg

Sawyer Cutler

unread,
Nov 3, 2019, 1:11:12 AM11/3/19
to Leonardo Ferreira, Flutter Development (flutter-dev)
Look into your code and find the line/block where it’s throwing the error. If it’s within a function, turn the function into async and add await to the calls inside it. That will usually fix the asynchronous suspension errors for flutter if they are basic.

You can email me with more details and send your code over and I can take a closer look. It’s hard without understanding what else is happening in that area of the code.

>
> On Nov 2, 2019, at 9:37 PM, Leonardo Ferreira <leona...@gmail.com> wrote:
>

Leonardo Ferreira

unread,
Nov 6, 2019, 4:13:50 AM11/6/19
to Flutter Development (flutter-dev)
I found the problem, in case of package we should use this property when using assets, 

Image(image: AssetImage ("atae_zeus/assets/images/splash.png", package: " atae_zeus "), width: 100,),

thank you all!!
Reply all
Reply to author
Forward
0 new messages