dnfield / flutter_svg

SVG parsing, rendering, and widget library for Flutter
MIT License
1.68k stars 459 forks source link

Null check operator used on a null value #934

Open aggeloskoutanis opened 1 year ago

aggeloskoutanis commented 1 year ago

Hello,

I have been getting this error since I upgrade the package to 2.0.4.

_CastError: Null check operator used on a null value
  File "loaders.dart", line 421, in SvgNetworkLoader.provideSvg
  File "loaders.dart", line 138, in SvgLoader._load.<fn>.<fn>
  File "_isolates_io.dart", line 18, in compute.<fn>
  File "isolate", line 954, in _RemoteRunner._run
  File "isolate_patch.dart", line 300, in _delayEntrypointInvocation.<fn>
  File "isolate_patch.dart", line 192, in _RawReceivePort._handleMessage

Does it have to do with the loader trying to access the image before it is loaded?

Flutter (Channel stable, 3.7.12, on macOS 13.3.1

Kayes-Islam commented 4 months ago

I have the same error on this SVG file: https://github.com/user-attachments/assets/1c6fd3a8-6f2b-48b8-8201-26489bd558a6

I have a number of other SVG files and they are working without problem.

I'm using version: 2.0.10+1

Kayes-Islam commented 4 months ago

OK so I did the below and now it's working:

  1. Got rid of couple of polygons that only had transform and fill like below:

    
     transform="translate(-0.020311,-25.843)"
    
     fill="#014953" />```
  2. Removed id attributes such as id="path27"
  3. Replaced style attribute with fill value to direct fill attribute. I.e. replaced style="fill:#014953" to fill="#014953"

Seems to be working now.

Kayes-Islam commented 4 months ago

I had issue in another file, this time removing the below is the only fix I had to apply: <polygon fill="#fff" transform="translate(.002336 -9.95283)"/> Confirmed that polygon without points is causing this issue.