Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.9k views
in Technique[技术] by (71.8m points)

android - Why won't a Flutter app that's embedded within an existing native iOS app load its own assets?

I've used Flutter's add-to-app documentation to run a small Flutter application as a native module inside an existing iOS app.

The Flutter app included some images in the pubspec.yaml from an assets folder like so:

assets:
  - assets/

According to Flutter docs, those assets are bundled with the app.

If I run the Flutter app on its own, it works fine. But when I run it in iOS, I get this error:

The following assertion was thrown resolving an image codec:
2021-01-11 14:41:51.204874-0800 flutter: Unable to load asset: assets/CONNECT.png

flutter: When the exception was thrown, this was the stack:
2021-01-11 14:41:51.205397-0800 flutter: #0      PlatformAssetBundle.load (package:flutter/src/services/asset_bundle.dart:227:7)

flutter: Image provider: AssetImage(bundle: null, name: "assets/CONNECT.png")
2021-01-11 14:41:51.209366-0800 flutter: Image key: AssetBundleImageKey(bundle: PlatformAssetBundle#893a5(), name: "assets/CONNECT.png",

Any documentation I find is talking about loading a Flutter asset in an iOS app or vice-versa. But this is a Flutter app loading its own assets in a native iOS app and I'm not sure of the fix.

Has anyone done this before and know what to do to resolve?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...