Kiran Kumar
Kiran Kumar

Reputation: 1600

How can we apply CSS stylings using Dart Language?

I have got problem in applying z-index through dart. Whats the correct way to do this

var carousel = query(".carousel");
  var classList = [];
  carousel.children.forEach(
      (childElement) => childElement.classes.forEach(
         (className) => classList.add(className)
          ));
  for (var i = 0; i < classList.length; i++) {
    query(classList[i]).style.zIndex+=1; //Need to increment z-index value for 
                                           the child divs incrementally
  }

Upvotes: 1

Views: 223

Answers (1)

Pixel Elephant
Pixel Elephant

Reputation: 21383

zIndex is a String so you can't increment it directly.

You can try this instead:

var elem = query(".${classList[i]}");
var newIndex = int.parse(elem.style.zIndex) + 1;
elem.style.zIndex = "${newIndex}";

Upvotes: 2

Related Questions