Flutter – Convert String to int and int to String

Here is how to convert String to int and int to String in Flutter or Dart.

String to int

You can use int.parse(data) to convert String to int.

Flutter String to int Example :

main () {
    var one = int.parse('1');
    print(one == 1); // prints true


Int to String

You can use intVariable.toString() to convert int to String.

Flutter int to String Example :

main () {
    String oneAsString = 1.toString();
    print(oneAsString == '1'); // prints true


If you find any better approaches, please feel free to add in comments section.

© 2020, https:. All rights reserved. On republishing this post, you must provide link to original post

Leave a Reply.. code can be added in <code> </code> tags