Skip to content
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

[Feature] Add package_name field to be able to use assets inside packages without assigning package name to every image widget. #13

Closed
abdelrahman-atef1 opened this issue Aug 20, 2024 · 1 comment

Comments

@abdelrahman-atef1
Copy link

Feature: Add package_name Field to flutter_assets configs for Asset Management

Explanation:

In Flutter, when using assets from a package, developers currently need to specify the package name for each asset individually in the Image widget or similar widgets. This can be repetitive and inefficient, especially when using multiple assets from the same package.

The proposed feature introduces a package_name field that can be added to the pubspec.yaml file under the flutter_assets: section. This field would allow developers to define the package name globally. As a result, assets could be used without repeatedly specifying the package name, improving code cleanliness and reducing redundancy.

For example, instead of writing:

Image.asset('assets/images/icon.png', package: 'my_package')

each time an asset is used, the package_name could be set once in the pubspec.yaml:

flutter_assets:
  package_name: my_package

Then, this would resolve to:

String icon = 'packages/my_package/assets/images/icon.png';
@weekitmo
Copy link
Owner

Nice suggestion.

weekitmo pushed a commit that referenced this issue Aug 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants