flutter_gen icon indicating copy to clipboard operation
flutter_gen copied to clipboard

ignore invalid asset names

Open ankiimation opened this issue 2 years ago • 3 comments

What does this change?

Ignore assets that has invalid name (start with number, equal a dart keyword,...)

Type of change

Please delete options that are not relevant.

  • [x] Bug fix (non-breaking change which fixes an issue)

Checklist:

Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • [x] Make sure to open a GitHub issue as a bug/feature request before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
    • [x] Ensure the tests (melos run unit:test)
    • [x] Ensure the analyzer and formatter pass (melos run format to automatically apply formatting)

ankiimation avatar Dec 27 '22 06:12 ankiimation

@ankiimation Thanks, I'll check it.

wasabeef avatar Jan 31 '23 15:01 wasabeef

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (a8d847d) 98.26% compared to head (c18bf74) 98.28%. Report is 65 commits behind head on main.

:exclamation: Current head c18bf74 differs from pull request most recent head 3be8ea0. Consider uploading reports for the commit 3be8ea0 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #346      +/-   ##
==========================================
+ Coverage   98.26%   98.28%   +0.01%     
==========================================
  Files          20       20              
  Lines         693      701       +8     
==========================================
+ Hits          681      689       +8     
  Misses         12       12              

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Feb 07 '23 06:02 codecov[bot]

also faced this issue on flutter 3.7.10

FlutterGen v5.2.0 Loading ... walk/pubspec.yaml
Unhandled exception:
Could not format because the source could not be parsed:

line 148, column 18 of .: Expected to find ';'.
    ╷
148 │           String get 01 =>  'assets/images/onboarding/01.svg';
    │                  ^^^
    ╵
line 148, column 22 of .: Expected a class member.
    ╷
148 │           String get 01 =>  'assets/images/onboarding/01.svg';
    │                      ^^
    ╵
line 148, column 25 of .: Expected an identifier.
    ╷
148 │           String get 01 =>  'assets/images/onboarding/01.svg';
    │                         ^^
    ╵
line 148, column 25 of .: Methods must have an explicit list of parameters.
    ╷
148 │           String get 01 =>  'assets/images/onboarding/01.svg';
    │                         ^^
    ╵
line 151, column 18 of .: Expected to find ';'.
    ╷
151 │           String get 02 =>  'assets/images/onboarding/02.svg';
    │                  ^^^
    ╵
line 151, column 22 of .: Expected a class member.
    ╷
151 │           String get 02 =>  'assets/images/onboarding/02.svg';
    │                      ^^
    ╵
line 151, column 25 of .: Expected an identifier.
    ╷
151 │           String get 02 =>  'assets/images/onboarding/02.svg';
    │                         ^^
    ╵
line 151, column 25 of .: Methods must have an explicit list of parameters.
    ╷
151 │           String get 02 =>  'assets/images/onboarding/02.svg';
    │                         ^^
    ╵
line 154, column 18 of .: Expected to find ';'.
    ╷
154 │           String get 03 =>  'assets/images/onboarding/03.svg';
    │                  ^^^
    ╵
line 154, column 22 of .: Expected a class member.
    ╷
154 │           String get 03 =>  'assets/images/onboarding/03.svg';
    │                      ^^
    ╵
(2 more errors...)
#0      DartFormatter.formatSource (package:dart_style/src/dart_formatter.dart:141:7)
#1      DartFormatter.format (package:dart_style/src/dart_formatter.dart:73:12)
#2      generateAssets (package:flutter_gen_core/generators/assets_generator.dart:190:20)
#3      FlutterGenerator.build (package:flutter_gen_core/flutter_generator.dart:61:25)
#4      main (file:///Users/egyleader/.pub-cache/hosted/pub.dev/flutter_gen-5.2.0/bin/flutter_gen_command.dart:48:49)
#5      _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:295:33)
#6      _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:192:26)
egyleader@Ahmeds-MacBook-Air walk % fluttergen -c pubspec.yaml
FlutterGen v5.2.0 Loading ... walk/pubspec.yaml
Unhandled exception:
Could not format because the source could not be parsed:

line 148, column 18 of .: Expected to find ';'.
    ╷
148 │           String get 01 =>  'assets/images/onboarding/01.svg';
    │                  ^^^
    ╵
line 148, column 22 of .: Expected a class member.
    ╷
148 │           String get 01 =>  'assets/images/onboarding/01.svg';
    │                      ^^
    ╵
line 148, column 25 of .: Expected an identifier.
    ╷
148 │           String get 01 =>  'assets/images/onboarding/01.svg';
    │                         ^^
    ╵
line 148, column 25 of .: Methods must have an explicit list of parameters.
    ╷
148 │           String get 01 =>  'assets/images/onboarding/01.svg';
    │                         ^^
    ╵
line 151, column 18 of .: Expected to find ';'.
    ╷
151 │           String get 02 =>  'assets/images/onboarding/02.svg';
    │                  ^^^
    ╵
line 151, column 22 of .: Expected a class member.
    ╷
151 │           String get 02 =>  'assets/images/onboarding/02.svg';
    │                      ^^
    ╵
line 151, column 25 of .: Expected an identifier.
    ╷
151 │           String get 02 =>  'assets/images/onboarding/02.svg';
    │                         ^^
    ╵
line 151, column 25 of .: Methods must have an explicit list of parameters.
    ╷
151 │           String get 02 =>  'assets/images/onboarding/02.svg';
    │                         ^^
    ╵
line 154, column 18 of .: Expected to find ';'.
    ╷
154 │           String get 03 =>  'assets/images/onboarding/03.svg';
    │                  ^^^
    ╵
line 154, column 22 of .: Expected a class member.
    ╷
154 │           String get 03 =>  'assets/images/onboarding/03.svg';
    │                      ^^
    ╵
(2 more errors...)
#0      DartFormatter.formatSource (package:dart_style/src/dart_formatter.dart:141:7)
#1      DartFormatter.format (package:dart_style/src/dart_formatter.dart:73:12)
#2      generateAssets (package:flutter_gen_core/generators/assets_generator.dart:190:20)
#3      FlutterGenerator.build (package:flutter_gen_core/flutter_generator.dart:61:25)
#4      main (file:///Users/egyleader/.pub-cache/hosted/pub.dev/flutter_gen-5.2.0/bin/flutter_gen_command.dart:48:49)
#5      _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:295:33)
#6      _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:192:26)

egyleader avatar Apr 09 '23 10:04 egyleader

We'd like to keep a solid solution in the package, so now we might move to #433 and continue discussions in #420. Thanks for the contribution!

AlexV525 avatar Mar 10 '24 07:03 AlexV525