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

Requires parameters to exclude directories. #170

Closed wasabeef closed 4 months ago

wasabeef commented 2 years ago

Please consider the following use-case:

assets/images/... -> should be generated
assets/data/... -> should not be generated

All files inside the data folder are simple data files, for example json or xml files. Which are used internally in the flutter application and therefore should not be considered as layout files (images, color, fonts etc.).

It would be great to have an exclude: property to defines those files or directories.

_Originally posted by @jayjah in https://github.com/FlutterGen/flutter_gen/issues/132#issuecomment-986102743_

wdcs-kishangohel commented 2 years ago

@wasabeef please merge this if it's correct. It's really needed.

Aristidios commented 1 year ago

Is it possible to generate all assets without specifying many paths - it gets complicated when you have many assets nested in multiple folders in your assets/ directory

vominhkhoi92 commented 1 year ago

Is it possible? Please help if it could be.

Is it possible to generate all assets without specifying many paths - it gets complicated when you have many assets nested in multiple folders in your assets/ directory

dev-shvetsov commented 3 months ago

Any updates?

AlexSeednov commented 3 months ago

Any updates?

Already done as I see - https://github.com/FlutterGen/flutter_gen/pull/276#issuecomment-1221519836

But I can't make it work..

I need to exclude fonts from generation, but it's not working. I tried

flutter_gen:
  output: lib/theme/asset
  line_length: 80

  integrations:
    flutter_intl: false
    flutter_svg: true

  assets:
    enabled: true

    output:
      style: dot-delimiter
      package_parameter_enabled: false

  fonts:
    enabled: false

and

flutter_gen:
  output: lib/theme/asset
  line_length: 80

  integrations:
    flutter_intl: false
    flutter_svg: true

  assets:
    enabled: true

    exclude: 
      - assets/font/

    output:
      style: dot-delimiter
      package_parameter_enabled: false

The same result. What's wrong?

Part of generated file

...
class $AssetsFontRobotoGen {
  const $AssetsFontRobotoGen();

  /// File path: assets/font/Roboto/LICENSE.txt
  String get license => 'assets/font/Roboto/LICENSE.txt';

  /// File path: assets/font/Roboto/Roboto-Black.ttf
  String get robotoBlack => 'assets/font/Roboto/Roboto-Black.ttf';

  /// File path: assets/font/Roboto/Roboto-BlackItalic.ttf
  String get robotoBlackItalic => 'assets/font/Roboto/Roboto-BlackItalic.ttf';
...

Flutter 3.19.3 • channel stable • https://github.com/flutter/flutter.git Framework • revision ba39319843 (2 weeks ago) • 2024-03-07 15:22:21 -0600 Engine • revision 2e4ba9c6fb Tools • Dart 3.3.1 • DevTools 2.31.1

flutter_gen_runner: ^5.4.0

AlexV525 commented 3 months ago

@AlexSeednov It is likely that you've put assets/font/ in your assets list. Remove them and your result will be as you desired.

AlexSeednov commented 3 months ago

@AlexSeednov It is likely that you've put assets/font/ in your assets list. Remove them and your result will be as you desired.

Maybe, but I need to include this font in assets

AlexV525 commented 3 months ago

Using those fonts in your application does not require you to write them in the assets list. Example: https://github.com/FlutterGen/flutter_gen/blob/584648dfdcb16fcfc937004e142201340518a9db/examples/example/pubspec.yaml#L74-L92

AlexSeednov commented 3 months ago

You're right, using font section near assets section is solving the problem, thanks. But using assets sections is much easier - as said here https://pub.dev/packages/google_fonts#bundling-fonts-when-releasing

AlexV525 commented 3 weeks ago

@AlexSeednov See https://github.com/FlutterGen/flutter_gen/issues/509#issuecomment-2169090864 and #529.