How to style SVG with Dart?

Issue

I am trying to styling the SVGElement but fail.Here is my code:

import 'dart:html';
import 'dart:svg';

main(){
    document.querySelector('#path').style.fill='none';//javascript: working, Dart: not working
}

How to make it working in Dart?

Solution

You can set the fill property of the CssStyleDeclaration even if it has no appropriate property like

document.querySelector('#circle').style.setProperty('fill', 'none');

This style is very useful if you get the property name as a string parameter.

Answered By – Günter Zöchbauer

Answer Checked By – Candace Johnson (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *