How to Convert Integer and Double to String in Flutter

There’s already a blog post published on how to convert string into integer and double in Flutter. Here, let’s check how to convert integer and double into string in Flutter.

Integer to String in Flutter

An Integer can be converted into string using toString function. See the code snippet given below.

var stringOne = 1.toString();

Double to String in Flutter

When you want to convert a number with decimals to string you can use toStringAsFixed() function. See the following code snippet.

var stringPi = 3.14159.toStringAsFixed(2);
print(stringPi); //3.14

The above example gives output 3.14 because we have given 2 to the toStringAsFixed function.

That’s how you change number to string in Flutter.

Similar Posts

Leave a Reply