-
-
Notifications
You must be signed in to change notification settings - Fork 873
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can not find asset when Flame Game is used as a module or package #3091
Comments
spydon sethladd angel333 ianliu domesticmouse Do you have any idea about it? Moderated: removed tags. |
@champ96k I'm sorry, I don't have anything to do with this project. |
Please don't tag all those Googlers in our issues, they are busy as it is. If you want quick answers I suggest that you join our discord instead, it's kind of rude to ping people like that in issues. |
Hey @spydon Thanks for response as i already drop this issue in discord, and will closely monitor this issue on discord As i debug this issue with flame repo as i found this issue is coming from below code Future<Image> _fetchToMemory(String name) async {
final data = await bundle.load('$_prefix$name');
final bytes = Uint8List.view(data.buffer);
return decodeImageFromList(bytes);
} This below line throwing an error final data = await bundle.load('$_prefix$name');
|
I just found one work around solution, When i calling our module or project then i need to create one name parameter for prefix and we need to override prefix parameter [package prefix param] Here i am calling/Navigating my module/package code, then that time i need to override prefix param, Just for reference below is the complete code. Navigator.of(context).push(
MaterialPageRoute(
builder: (ctx) => Klondike(
prefix: 'packages/klondike_package/assets/images/',
),
),
); class Klondike extends GameWidget<KlondikeGame> {
Klondike({super.key, required this.prefix})
: super(game: KlondikeGame(prefix: prefix));
final String prefix;
} class KlondikeGame extends FlameGame {
KlondikeGame({required this.prefix}) : super(camera: CameraComponent());
@override
FutureOr<void> onLoad() async {
images.prefix = prefix;
}
} |
As of now closing this issue, feel free to re-open if you find any difficulty. |
This is not working when we host the package on github |
It should not matter where the package originates, as long as the package name is correct. |
What happened?
I'm developing a game using the Flutter Flame engine and have packaged the game to be used in another Flutter app. However, I'm encountering an issue where the game, when used as a package dependency in the host app, cannot find its image assets.
My Flame game has its assets located in assets/images/ and they are properly listed in the pubspec.yaml of the game package. It loads the image like this:
However, when integrating this game package into another Flutter app as a module and trying to run the app, the game fails to load its image assets. It seems like the game package is unable to locate the assets directory.
The game fails to load its image assets when used as a package dependency in another Flutter app.
What do you expect?
The game, when integrated as a package dependency, should be able to locate and load its image assets successfully.
How can we reproduce this?
What steps should take to fix this?
No response
Do have an example of where the bug occurs?
NA
Relevant log output
! Doctor found issues in 2 categories.
The text was updated successfully, but these errors were encountered: