Get access to an object's property using bracket notation in dart

徘徊边缘 提交于 2019-12-07 07:32:49

问题


I try to do the following:

var properties = ["height" , "width"];
for (var prop in properties){
  div.style[prop] = otherdiv.style[prop];
}

But dart doesn't seem to accept this bracket notation, is there any other way to access a property using a string in dart ?


回答1:


You can use the getPropertyValue and setProperty methods like

div.style.setProperty(prop, otherdiv.style.getPropertyValue(prop));


来源:https://stackoverflow.com/questions/28262768/get-access-to-an-objects-property-using-bracket-notation-in-dart

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!