You can parse a string into an integer with int.parse(). For example:
var myInt = int.parse('12345');
assert(myInt is int);
print(myInt); // 12345
Note that int.parse() accepts 0x prefixed strings. Otherwise the input is treated as base-10.
You can parse a string into a double with double.parse(). For example:
var myDouble = double.parse('123.45');
assert(myDouble is double);
print(myDouble); // 123.45
parse() will throw FormatException if it cannot parse the input.
BezKoder
bezkoder.com › home › how to parse a string into a number in dart/flutter
How to parse a String into a number in Dart/Flutter - BezKoder
April 1, 2022 - Sometimes we have to work with string in radix number format. Dart int parse() method also supports convert string into a number with radix in the range 2..36:
Videos
Top answer 1 of 13
490
You can parse a string into an integer with int.parse(). For example:
var myInt = int.parse('12345');
assert(myInt is int);
print(myInt); // 12345
Note that int.parse() accepts 0x prefixed strings. Otherwise the input is treated as base-10.
You can parse a string into a double with double.parse(). For example:
var myDouble = double.parse('123.45');
assert(myDouble is double);
print(myDouble); // 123.45
parse() will throw FormatException if it cannot parse the input.
2 of 13
163
In Dart 2 int.tryParse is available.
It returns null for invalid inputs instead of throwing. You can use it like this:
int val = int.tryParse(text) ?? defaultValue;
Flutter
api.flutter.dev › flutter › dart-core › int › parse.html
parse method - int class - dart:core library - Dart API
Rather than throwing and immediately catching the FormatException, instead use tryParse to handle a potential parsing error. Example: var value = int.tryParse(text); if (value == null) { // handle the problem // ... } external static int parse(String source, {int? radix}); Flutter · dart:core ·
Programming Idioms
programming-idioms.org › idiom › 22 › convert-string-to-integer › 203 › dart
Convert string to integer, in Dart
Convert string to big integer · Cheatsheets · Issues · Report a bug · × · Dart · var i = int.parse(s); Ada · I : Integer := Integer'Value (s); C · i = (int)strtol(s, (char **)NULL, 10); C · int i = atoi(s); Clojure · (def i (Integer/parseInt s)) Clojure ·
Medium
medium.com › nextfunc › dart-flutter-how-to-parse-string-to-number-22c6e181e599
Dart/Flutter — How to parse String to number | by Phuc Tran | Nextfunc Co., Ltd | Medium
November 7, 2020 - /// Parse string to integer without handling error /// -> throw exception at runtime. int stringToInt_parseWithoutErrorHandle(String input) { return int.parse(input); }void main() { final testInvalidNumber = 'a'; print(stringToInt_parseWithoutErrorHandle( testInvalidNumber) ); } ... Unhandled exception: FormatException: Invalid radix-10 number (at character 1) a ^ #0 int._throwFormatException (dart:core-patch/integers_patch.dart:131:5) #1 int._parseRadix (dart:core-patch/integers_patch.dart:142:16) #2 int._parse (dart:core-patch/integers_patch.dart:100:12) #3 int.parse (dart:core-patch/integer
Dart
api.dart.dev › dart-core › int › toString.html
toString method - int class - dart:core library - Dart API
dart:core · int · toString abstract method · toString · dark_mode light_mode · description · String toString( ) override · Returns a string representation of this integer. The returned string is parsable by parse. For any int i, it is guaranteed that i == int.parse(i.toString()).
Codecademy
codecademy.com › docs › dart › type conversion
Dart | Type Conversion | Codecademy
April 22, 2024 - Converts a string representation of data into a specified data type. ... Returns the double representation of the numerical value. ... Converts numeric values to integers.
GitHub
github.com › dart-lang › sdk › issues › 2624
Convert hex string to int should exit. · Issue #2624 · dart-lang/sdk
April 17, 2012 - Currently, it's implement in the lib/ui style.dart file. /** * [hex] hexidecimal string to convert to scalar. * returns hexidecimal number as an integer. * throws BadNumberFormatException if [hex] isn't a valid hex number.
Author terrylucas
Python Examples
pythonexamples.org › dart › how-to-convert-string-to-integer
How to Convert String to Integer in Dart
We create a variable named str with a string value of "012". We then use the int.parse() function to convert it to an integer and store the result in the variable number.
Dart Tutorial
darttutorial.org › home › dart tutorial › dart int
Dart int
May 27, 2022 - void main() { int counter = 1; print('counter: $counter'); }Code language: Dart (dart) ... To convert a string into an integer, you use the int.parse().
DhiWise
dhiwise.com › post › flutter-string-to-double-converting-data-with-precision
Flutter String to Double: A Step-by-Step Guide
April 3, 2025 - In Dart, you can create a string by enclosing the desired sequence of characters within single or double quotes. For instance, String str = "Hello, World!"; is a valid string in Dart. The input string is the string that we want to convert or parse. We can convert this input string to other data types, such as int or double.
Codecademy
codecademy.com › docs › dart › type conversion › .toint()
Dart | Type Conversion | .toInt() | Codecademy
April 30, 2024 - In Dart, the .toInt() method is used to convert numeric values, like doubles or strings representing numbers, to integers.
Dart
dart.dev › resources › language › number-representation
Numbers in Dart
August 7, 2025 - However, int values are always also double values, which can lead to some surprises. ... Most integer and double arithmetic has essentially the same behavior. There are, however, important differences—particularly when your code has strict expectations about precision, string formatting, or underlying runtime types.