Parse String to int or double in Dart Flutter

By November 11, 2020 February 3rd, 2021 No Comments

How to parse a String into an Int in Dart.

String myString = "1";

Remember to use try and catch since it can throw FormatException.

Or you can try to parse it!


So no need to wrap it in a try catch, since it will return null in case it fails to parse that String into an integer.


You can use the same with double.


Note: onError callback is deprecated


Author Ernie

More posts by Ernie