change length of svg line in DART

Issue

I have SVG line in HTML and want to change the end coordinate.

 <svg  xmlns="http://www.w3.org/2000/svg" version="1.1" >   
   <line id="myline" x1="0" y1="0" x2="200" y2="200"
        style="stroke:rgb(255,0,0);stroke-width:2"/>  
 </svg>

In Dart code I have the following:

LineElement line = query("#myline");

I need to change x2 from 200 to 220 but I don’t see x2 attribute for line.
Is it possible to do that?

Solution

LineElement does have the x2 attribute as you can see in the docs http://api.dartlang.org/docs/releases/latest/dart_svg/LineElement.html#x2.

You can set x2 through either of the following methods:

line.attributes["x2"] = "220";
line.$dom_setAttribute("x2", "220");

Answered By – Pixel Elephant

Answer Checked By – David Goodson (FlutterFixes Volunteer)

Leave a Reply

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