FlutterGen / flutter_gen

The Flutter code generator for your assets, fonts, colors, … — Get rid of all String-based APIs.
https://pub.dev/packages/flutter_gen
MIT License
1.44k stars 142 forks source link

[FR]: Generate assets from subpackages into main package #391

Closed natintosh closed 1 week ago

natintosh commented 1 year ago

Is there an existing issue for this?

Describe the problem

I am not sure if this is possible or if this feature is already possible but to put it more concisely, I am not able to generate assets from a sub package

Describe the solution

I would like FlutterGen to generate assets from resources from other packages. for instance

/my_resource_package
  /assets
    /icon_1.png
    /icon_2.png
 /lib
  /others_components
pubspec.yaml    <<< Declare assets in here
/my_app
  /assets
    /others_assets
  /lib
   /gen
     assets.gen.dart     <<< Generated assets class that contains assets from my_resource_package and my_app
  pubspec.yaml           <<< flutter_gen dependencies and configurations

Additional context

No response

Code of Conduct

bramp commented 3 months ago

If it helps, I have subpackages and I generate assets.gen.dart for each subpackage. Then I just do something like this:

import 'package:ui' as ui;
import 'package:icons' as icons;

build() {
  Widget(img: ui.Assets.buttton...
...
AlexV525 commented 1 week ago

The scope of build_runner doesn't seem to include packages, the feature might only be available through the command line. However, extending such ability will significantly increase the complexity of the implementation and destination management, also making exceptions across packages hard to recognize. With the latest version of the package, you can easily generate assets as package assets and use them without pain (.image(), .svg(), etc). Thus I'm closing the request as overwhelming to the package.