flutter_gen icon indicating copy to clipboard operation
flutter_gen copied to clipboard

Requires parameters to exclude directories.

Open wasabeef opened this issue 3 years ago • 3 comments

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

wasabeef avatar Dec 10 '21 12:12 wasabeef

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

wdcs-kishangohel avatar Jul 06 '22 10:07 wdcs-kishangohel

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

Aristidios avatar Jul 08 '22 13:07 Aristidios

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

vominhkhoi92 avatar Jun 15 '23 04:06 vominhkhoi92

Any updates?

dev-shvetsov avatar Mar 10 '24 20:03 dev-shvetsov

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

AlexSeednov avatar Mar 23 '24 23:03 AlexSeednov

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

AlexV525 avatar Mar 24 '24 02:03 AlexV525

@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

AlexSeednov avatar Mar 24 '24 09:03 AlexSeednov

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

AlexV525 avatar Mar 24 '24 09:03 AlexV525

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

AlexSeednov avatar Mar 24 '24 21:03 AlexSeednov