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.48k stars 150 forks source link

[BUG]: flutter_svg integrations broken with vector_graphics_compiler #537

Closed Conrad33 closed 4 months ago

Conrad33 commented 4 months ago

Is there an existing issue for this?

Version

5.6.0

Command type

build_runner (Default)

What happened?

Now that #530 is merged, there is support for asset transformation. However, when using vector_graphics_compiler the .svg() integrations throw an error at runtime due to failing to parse XML. It seems that flutter_gen expects the .svg files to not be compiled.

I opted to label this issue as a bug instead of a feature request because the error is only encountered at runtime, but feel free to change.

Relevant a pubspec.yaml.

flutter:
  assets:
    - path: assets/logo.svg
      transformers:
        - package: vector_graphics_compiler

Relevant log output

Error
dart-sdk/lib/internal/js_dev_runtime/private/ddc_runtime/errors.dart 296:3  throw
packages/xml/src/xml_events/iterator.dart 43:9                               moveNext
packages/vector_graphics_compiler/src/svg/parser.dart 673:27                 _readSubtree
packages/vector_graphics_compiler/src/svg/parser.dart 764:19                 [_parseTree]
packages/vector_graphics_compiler/src/svg/parser.dart 799:5                  parse
packages/vector_graphics_compiler/vector_graphics_compiler.dart 76:16        parse
packages/vector_graphics_compiler/vector_graphics_compiler.dart 143:5        encodeSvg
packages/flutter_svg/src/loaders.dart 168:14                                 <fn>
packages/flutter_svg/src/utilities/compute.dart 12:38                        _testCompute
packages/flutter_svg/src/loaders.dart 154:21                                 <fn>
dart-sdk/lib/async/zone.dart 1661:54                                         runUnary
dart-sdk/lib/async/future_impl.dart 163:18                                   handleValue
dart-sdk/lib/async/future_impl.dart 847:44                                   handleValueCallback
dart-sdk/lib/async/future_impl.dart 876:13                                   _propagateToListeners
dart-sdk/lib/async/future_impl.dart 652:5                                    [_completeWithValue]
dart-sdk/lib/async/future_impl.dart 722:7                                    callback
dart-sdk/lib/async/schedule_microtask.dart 40:11                             _microtaskLoop
dart-sdk/lib/async/schedule_microtask.dart 49:5                              _startMicrotaskLoop
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 181:7           <fn>

Code of Conduct

AlexV525 commented 4 months ago

You'll need to use the raw path to combine with the transformer. The generated file knows nothing with the defined transformers.