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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Add support for adding assets from a package #50

Closed
jorgecoca opened this issue Nov 4, 2020 · 5 comments 路 Fixed by #98
Closed

[Feature Request] Add support for adding assets from a package #50

jorgecoca opened this issue Nov 4, 2020 · 5 comments 路 Fixed by #98
Assignees
Labels
contributions welcome Welcome contribute
Milestone

Comments

@jorgecoca
Copy link

Hello! 馃憢

As a developer, I work on packages that need to contain assets. When that happens, those assets need to be referenced in a different way (see links below):

It'd be amazing for flutter_gen to support this use case.

If you believe this is a valid use case, I'd be more than happy to take a look and come up with a proposal / pull request.

Thank you! 馃挴

@wasabeef wasabeef modified the milestones: 1.3.0, 1.x.x Nov 14, 2020
@wasabeef wasabeef added the contributions welcome Welcome contribute label Nov 14, 2020
@wasabeef
Copy link
Member

I'm also thinking about the best way.
If anyone has a good idea, it would be helpful if you could get a pull request.

@korzonkiee
Copy link

korzonkiee commented Jan 8, 2021

Hey!

I think a have an idea for a potential solution that might solve that problem.

We could:

  1. Extend FlutterGen with an additional package parameter, so that the user can define it as follows:
flutter_gen:
  output: lib/generated/
  package: my_ui_package
  lineLength: 80
  integrations:
    flutter_svg: true
  1. Modify _assetGenImageClassDefinition so that it takes package parameter. It would require transforming this constant string value into a parameterized function.
  2. Pass the package parameter to the AssetImage.super(assetName, package) super constructor.

Additionally, SVG integration would need to be updated as follows:

  1. Convert Integration.classOutput getter to method with package argument.
  2. Pass package as a default value for SvgPicture.package field.

Let me know what you think about that solution @wasabeef @jorgecoca

@lcdsmao lcdsmao self-assigned this Mar 30, 2021
@wasabeef wasabeef modified the milestones: 1.x.x, 3.1.0 Mar 30, 2021
@lcdsmao lcdsmao mentioned this issue Apr 8, 2021
@orestesgaolin
Copy link

orestesgaolin commented Jun 9, 2021

I saw that this landed in 3.1.1 but somehow my assets aren't generated with package parameter:

Edit: I had installed fluttergen both through brew and pub, older version was overtaking the new one. Fixed by removing one from brew.

@wasabeef
Copy link
Member

Thanks

@om-ha
Copy link

om-ha commented Jul 4, 2022

Hey @jorgecoca

As an app developer following this issue's approach, we want to consume the package's assets. Do we have to set every single image asset as an entry in the consumer app's pubspec.yaml file? I hope there's a way to overcome this otherwise it would be too verbose.

See this article -> Example 1: shrine_images -> How an app developer uses the package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributions welcome Welcome contribute
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants