Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I'm trying use flutter svg, but load with black svg

Tags:

svg

flutter

I'm trying to use Flutter SVG dependency, i put in the svg in assets, set in pubspec.yaml, and set in my widget, but, the svg load with black container

I've already tried change the svg, and the another svg works fine, but the other not...

    final Widget svg = SvgPicture.asset(assetName, semanticsLabel: 'Acme Logo');

the svg in flutter

Here the svg

My expected response was colored svg like the link in codepen, but i got this

like image 230
Lucas Buchalla Sesti Avatar asked Oct 26 '19 03:10

Lucas Buchalla Sesti


People also ask

Why is my SVG filled black?

If you upload a complex design into Design Space it may give you both “cut” and “print and cut” options. If that happens, the cut-only image will be black. Hi Lilit, are you uploading the SVG or PNG file? Did you upload a PNG file and “save as a cut file” or did you upload the SVG from the beginning?

How do I import SVG into Flutter?

First, go and create the folder called images in the root structure and add any SVG image which you like. Then open the pubspec. yaml and specify your file name under the assets. Next you can load the file from asset as mentioned in below.

Does Flutter accept SVG?

Using SVG in FlutterSkia, a 2D graphics library and core component of Flutter, can only serialize images into SVG files. Thus, decoding or rendering SVG images with Skia is not possible.

Does flutter_SVG work with SVG files?

Here you can see your SVGs' cleaned successfully. After cleaning, you can grab those SVG files from the output folder location and add those files into your flutter app without seeing any black coloured SVG. It works perfectly fine for me. Show activity on this post. flutter_svg can not understand Internal or Embedded CSS.

How to use flutter_SVG in Flutter App?

There are multiple ways to use flutter_svg in your Flutter app. One way is to load an SVG Image from an internal SVG file, which can be in the asset folder of our flutter app:

Why is my SVG file not displaying properly?

This is probably happened because of the corrupted SVG files from the internet. I faced this problem earlier and tried many ways to solve it. But finally, I solved it with the help of this software, svgcleaner. import your SVG. Click run. Success!

How to load an SVG from an SVG code?

Finally, you can load an SVG from an SVG code: Once you have your SVG file loaded, the first step is to change the color or tint of the image: Using a semantics label helps to describe the purpose of the image and enhances accessibility.


3 Answers

This is probably happened because of the corrupted SVG files from the internet. I faced this problem earlier and tried many ways to solve it. But finally, I solved it with the help of this software, svgcleaner.

Download the application into your OS, from here

After installation,

  1. import your SVG.

importsvg

  1. Click run.

run

  1. Success! Here you can see your SVGs' cleaned successfully.

success

After cleaning, you can grab those SVG files from the output folder location and add those files into your flutter app without seeing any black coloured SVG.

It works perfectly fine like this.

enter image description here

like image 101
Alif Avatar answered Oct 24 '22 03:10

Alif


I think I am late but this might just help someone. Just make all the styles in your svg image use inline styling otherwise all colors and styling won't be rendered as the tag is not readable by the SvgPicture.

like image 37
Sparks Avatar answered Oct 24 '22 04:10

Sparks


I tried this SVG asset with the latest version of jovial_svg, and it works great! Here's the result:

Screen Shot

This version of jovial_svg should be released in a couple of days, but for now it's 1.1.4-rc.4.

(This asset helped me flesh out stylesheet support - thanks!)

like image 1
Bill Foote Avatar answered Oct 24 '22 03:10

Bill Foote