You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a modular architecture with multiple packages and in one of my packages i added a assets folder assets/images/headphone.jpg once the build runner is generate a assets.gen.dart
class $AssetsImagesGen {
const $AssetsImagesGen();
/// File path: assets/images/headphone.jpeg
AssetGenImage get headphone =>
const AssetGenImage('assets/images/headphone.jpeg');
/// List of all assets
List<AssetGenImage> get values => [headphone];
}
Since the file path is const assets/images/headphone.jpeg it can't find it the actual file path should be packages/product/assets/images/headphone.jpeg
Relevant a pubspec.yaml.
name: productdescription: A new Flutter package project.version: 0.0.1publish_to: nonehomepage:
environment:
sdk: '>=3.0.2 <4.0.0'flutter: ">=1.17.0"dependencies:
flutter:
sdk: fluttercommon:
path: ../commoncore:
path: ../corecart:
path: ../cartdependency_overrides:
intl: ^0.17.0collection: ^1.17.1test_api: ^0.5.1dev_dependencies:
flutter_test:
sdk: flutterflutter_lints: ^2.0.1hive_generator: ^2.0.0hive_test: ^1.0.1build_runner: ^2.3.2envied_generator: ^0.3.0retrofit_generator: '>=4.0.0 <5.0.0'json_serializable: '^6.6.1'freezed: ^2.3.2riverpod_generator: ^2.2.0mockito: ^5.4.0flutter_gen_runner: ^5.3.1# For information on the generic Dart part of this file, see the# following page: https://dart.dev/tools/pub/pubspec# The following section is specific to Flutter packages.flutter:
uses-material-design: true# To add assets to your package, add an assets section, like this:assets:
- assets/images/
Relevant log output
No response
Code of Conduct
I agree to follow this project's Code of Conduct
The text was updated successfully, but these errors were encountered:
Found out that if you specify the package name while the asset comes from a package or module, the asset will be displayed. Is there a way to make this more convenient? I mean, to needlessly put the package name each time you use an asset from a package/module.
Found out that if you specify the package name while the asset comes from a package or module, the asset will be displayed. Is there a way to make this more convenient? I mean, to needlessly put the package name each time you use an asset from a package/module.
Solved it by doing the following, can finally read the assets from packages. Hope this helps
Is there an existing issue for this?
Version
^5.3.1
Command type
build_runner (Default)
What happened?
I have a modular architecture with multiple packages and in one of my packages i added a assets folder
assets/images/headphone.jpg
once the build runner is generate aassets.gen.dart
Since the file path is const
assets/images/headphone.jpeg
it can't find it the actual file path should bepackages/product/assets/images/headphone.jpeg
Relevant a pubspec.yaml.
Relevant log output
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: