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.

Answer from Seth Ladd on Stack Overflow
🌐
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:
🌐
Dart Tutorial
dart-tutorial.com › convert string to int › dart how to › dart tutorial - learn dart programming
Convert String to Int :: Dart Tutorial - Learn Dart Programming
The String is the textual ... data from one type to another type. In dart, you can convert String to int by using the int.parse() method....
🌐
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 ·
🌐
DEV Community
dev.to › thphuc › dart-flutter-how-to-parse-string-to-number-j79
Dart/Flutter — How to parse String to number - DEV Community
November 7, 2020 - In this post, let’s learn a few methods to parse/convert String to number (integer, double or both)... Tagged with dart, flutter, stringtonumber, nextfunc.
🌐
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
🌐
Reactgo
reactgo.com › home › how to convert the string to an int in dart
How to Convert the String to an Int in Dart | Reactgo
July 1, 2023 - void main() { var a = "21"; var num = int.parse(a); // converts string to int print(num); } ... Similarly, we can also convert the string to double by using the double.parse() method in Dart.
Find elsewhere
🌐
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()).
🌐
DhiWise
dhiwise.com › post › the-ultimate-guide-to-dart-type-cast-converting-data-types
Dart Type Cast: Converting Between Data Types
September 6, 2024 - Dart provides several methods to cast types. Let's delve into some examples. In Dart, you can cast a string to an integer using the int.parse() method.
🌐
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.
🌐
Bacancy Technology
bacancytechnology.com › qanda › flutter › parse-a-string-to-a-number-in-dart
How to Parse a String to a Number in Dart: Complete Guide
April 18, 2025 - Learn how to parse a string to a number in Dart. Includes examples and error handling tips.
🌐
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.
🌐
Bacancy Technology
bacancytechnology.com › qanda › flutter › convert-a-double-to-an-int-in-dart
How to Convert a Double to an Int in Dart: A Complete Guide
July 5, 2024 - Description: Converts the double to an integer by discarding the fractional part. This method rounds towards zero. There are no difference between toInt() and truncate() method. ... Description: Rounds a number to the nearest integer.