flutter_gen icon indicating copy to clipboard operation
flutter_gen copied to clipboard

Cannot generate from assets with package in its path

Open Aqluse opened this issue 2 years ago • 2 comments

As stated, it seems just like ignoring it. So I have looked through related code and found a very interesting lines that I suspect cause that (without debugging it).

Looks like a function _getAssetRelativePathList (used in every variant of case style) has only two conditions to add paths from pubspec assets, I think both of these conditions ending up with 'false' and function silently drops such paths (like it's a good way to handle this, which is surely not). Conditions are: FileSystemEntity.isDirectorySync / FileSystemEntity.isFileSync

https://github.com/FlutterGen/flutter_gen/blob/de64e755d9a1d72cf70f892cf4107364388bff27/packages/core/lib/generators/assets_generator.dart#L99

Aqluse avatar Aug 09 '22 14:08 Aqluse

I was right about this, I have put these lines:

stdout.writeln('Assets:');
  stdout.writeln(assets.length);
  stdout.writeln(assets);
  stdout.writeln('Relativized asset paths:');
  stdout.writeln(assetRelativePathList.length);
  stdout.writeln(assetRelativePathList);

which gives me an output:

Assets:
5
[packages/.../assets/resources/snackbar/action-close.svg, packages/.../assets/resources/snackbar/action-redirect.svg, packages/.../assets/resources/snackbar/status-info.svg, packages/.../assets/resources/snackbar/status-success.svg, packages/.../assets/resources/snackbar/status-warning.svg]
Relativized asset paths:
0
[]

Aqluse avatar Aug 10 '22 15:08 Aqluse

@Aqluse Could you verify if #471 resolves the issue?

AlexV525 avatar Mar 07 '24 03:03 AlexV525