我是Flutter的新手,我想知道(对我来说)如何解决如何将变量var int counter = 0转换为解决方案有多困难?放入变量var String $ counter =“ 0”;
我进行了很多搜索,但根本没有发现类似var myInt = int.parse('12345');的内容。
不适用于var myInt = int.parse(counter);
特别感谢您的建议
Ric*_*eap 13
使用toString和/或toRadixString
int intValue = 1;
String stringValue = intValue.toString();
String hexValue = intValue.toRadixString(16);
Run Code Online (Sandbox Code Playgroud)
或者,如在纪念中
String anotherValue = 'the value is $intValue';
Run Code Online (Sandbox Code Playgroud)
bra*_*b0y 13
String s = "45";
int i = int.parse(s);
Run Code Online (Sandbox Code Playgroud)
int j = 45;
String t = "$j";
Run Code Online (Sandbox Code Playgroud)
// 如果后者看起来很奇怪,请查看https://dart.dev 上的字符串插值
您可以在 int 类中使用 .toString() 函数。
int age = 23;
String tempAge = age.toString();
Run Code Online (Sandbox Code Playgroud)
那么你可以简单地将整数转换为字符串。
| 归档时间: |
|
| 查看次数: |
6429 次 |
| 最近记录: |