I want to display a double (or int) similar to how you would a string with a Text()
widget. Is there an equivalent to this widget for ints or doubles in Flutter? Sorry if this is obvious, but I could not find anything.
CodePudding user response:
You use a Text
widget for this as well, simply use string interpolation to display your variables as a String
:
final int two = 2;
final double pi = 3.14;
return Text("$two is an integer, and $pi is a double.");
You can also use the toString()
method on any object in Dart (which is what the string interpolation above does implicitly). So if you want to print a double by itself, it's possible to write:
Text(pi.toString());
More on Strings and interpolation
CodePudding user response:
Text("${<Your double/int variable>"})