-
Notifications
You must be signed in to change notification settings - Fork 26
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
Assets not found for package project #122
Comments
It should work. Here is a story which loads an image asset using the package name: https://github.com/Dropsource/scratch_image/blob/main/scratch_image/stories/images_stories.dart |
that different from my setup. this is widget https://github.com/natt-han/monarch_test/blob/main/lib/asset_widget.dart |
It only makes sense to use the Try creating and referring to a different package name and make sure you call |
but this is how I want It to be. the example repo is a package type project. I want to set up monarch in a package project so that I can build and test it quickly from the package project it self, but I found this problem. |
Unless I'm mistaken but based on that, you should use Let's call the package containing AssetWidget 'asset_widget_package'
|
In It same as Icons packages like this one that have to use |
@natt-han, you are correct on how you want to use the If you add a main.dart to To use your assets within Monarch here are 3 options:
/// asset_widget.dart
class AssetWidget extends StatelessWidget {
final String? package;
AssetWidget({super.key, this.package = 'monarch_test'});
@override
Widget build(BuildContext context) {
return Image.asset('assets/flutter.png', package: package);
}
}
/// asset_widget_stories.dart
Widget assetWidget() => AssetWidget(package: null);
/// from another project you won't need to pass package, you could just call:
AssetWidget() I hope this helps. |
I'm not sure is Monarch support set up inside package project?
I found a problem that monarch can't find assets.
In my widget I load assets with my package name
SvgPicture.asset( 'assets/images/header_bg.svg', package: 'my_package', ),
I found a work around to make It work by copy files from '.monarch/flutter_assets/assets/images' to '.monarch/flutter_assets/packages/my_package/assets/images'
The text was updated successfully, but these errors were encountered: