如何以数组的形式获取dart类carousel的子元素的类名?
<div class="carousel">
<div class="galleryCars">
....
</div>
<div class="galleryCars2">
....
</div>
<div class="galleryCars3">
....
</div>
<div class="galleryCars4">
....
</div>
</div>
答案 0 :(得分:5)
以下是如何获得Set个子类名称:
query('.carousel').children.expand((e) => e.classes).toSet();
答案 1 :(得分:4)
快点肮脏:
var carousel = query(".carousel");
var classList = [];
carousel.children.forEach((childElement) => classList.addAll(childElement.classes));
print(classList); // [galleryCars,galleryCars2,galleryCars3,galleryCars4]