flutter_gen icon indicating copy to clipboard operation
flutter_gen copied to clipboard

[FR]: Generate assets from subpackages into main package

Open natintosh opened this issue 2 years ago • 1 comments

Is there an existing issue for this?

  • [x] I have searched the existing issues

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

  • [X] I agree to follow this project's Code of Conduct

natintosh avatar May 11 '23 05:05 natintosh

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...
...

bramp avatar Apr 07 '24 03:04 bramp

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.

AlexV525 avatar Jun 27 '24 02:06 AlexV525