dart - 更改DART中svg行的长度

标签 dart dart-html

我在HTML中有SVG行,并且想要更改结束坐标。

 <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>

在Dart代码中,我具有以下内容:

LineElement line = query("#myline");

我需要将x2从200更改为220,但我看不到行的x2属性。
有可能这样做吗?

最佳答案

正如您在http://api.dartlang.org/docs/releases/latest/dart_svg/LineElement.html#x2文档中所见,LineElement确实具有x2属性。

您可以通过以下两种方法之一设置x2:

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

关于dart - 更改DART中svg行的长度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16679388/

相关文章:

dart - Dart 中的工作音频循环示例

sqlite - 升级 SQFLITE : Unhandled Exception: DatabaseException(table UsernameTable has no column named rememberMe (Sqlite code 1):

Flutter:按下按钮时播放声音

dart - Dart 2与TypeScript的 `typeof`等效吗?

html - Assets 图像未在 flutter-ios 中呈现。如何在不使用 webview 的情况下在 flutter 中渲染 html <img src ...> 标签内的本地 Assets 图像?

Dart:如何修复条件?

Dart http_server 服务 index.html 但不拉依赖

dart - 如何使用 Dart 在 IndexedDB 中使用复合键创建对象存储

flutter - 在pana和pub.dev上启用nnbd实验

Flutter Canvas.drawImage() 绘制像素化图像