0Pricing
Dart Academy · Lesson

Parsing and Converting Numbers

Turn strings into numbers and back.

Text Is Not a Number

User input and files arrive as strings. The text "42" cannot do math until you parse it into a real number first. 🔄

Parse to an int

Call int.parse to turn a digit string into an int. The result is a true number you can add, compare, or store.

void main() {
  int n = int.parse('42');
  print(n + 1); // 43
}

All lessons in this course

  1. Arithmetic and Operator Precedence
  2. int vs double and Integer Division
  3. Parsing and Converting Numbers
  4. The dart:math Toolkit
← Back to Dart Academy