title: Dart: How to iterate digits of integer?
body: <p>How to iterate digits of integer? for example sum of digits here, it works, but is any way to right way?</p>
  <pre><code>int sumOfDigits(int num) {
    int sum = 0;
    String numtostr = num.toString();
    for (var i = 0; i &lt; numtostr.length; i++) {
      sum = sum + int.parse(numtostr[i]);
    }
    return sum;
  }
  </code></pre>