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.43k stars 142 forks source link

[BUG]: Build Issue with FlutterGen When Excluding Paths with Special Characters in Filenames #509

Closed sAtluna closed 1 week ago

sAtluna commented 2 months ago

Is there an existing issue for this?

Version

5.4.0

Command type

build_runner (Default)

What happened?

Hello,

I've been using your package and encountered a specific problem when excluding directories in pubspec.yaml for FlutterGen. This issue involves handling filenames with special characters, such as a plus sign (+), which aren't processed correctly despite being in an excluded directory.

Configuration:

flutter_gen:
  output: lib/assets/
  assets:
    outputs:
      class_name: MyAssets
    exclude:
      - assets-extern/

Problem: Despite excluding the assets-extern/directory, FlutterGen processes files from this directory, leading to a build error:

Operator declarations must be preceded by the keyword 'operator'.
AssetGenImage get myasset+ffffff => const AssetGenImage('assets-extern/myasset+_fffff.jpg');

It seems, that FlutterGen is parsing first everything and then applying a filter with the declared excluded paths. I understand this is a very special case due to the unique filenames connected to our database models. However, I confirmed the build runner recognizes this configuration. Is there a possible solution to handle filenames with special characters?

Thank you!

Relevant a pubspec.yaml.

flutter_gen:
  output: lib/assets/ 

  assets:
    outputs:
      class_name: MyAssets

    exclude:
      - assets-extern/

Relevant log output

Operator declarations must be preceded by the keyword 'operator'.

        AssetGenImage get myasset+ffffff => const AssetGenImage('assets-extern/myasset+_fffff.jpg');

Code of Conduct

AlexV525 commented 2 weeks ago

I'm not seeing the behavior with v5.5.0. Could you confirm the issue persists? I've also checked the implementation, it seems that the exclude section uses Glob to parse entries, which assets-extern/* is a valid key in this case.

AlexV525 commented 2 weeks ago

See #529