Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/dart/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter 颤振-将字符串变量转换为整数_Flutter_Dart - Fatal编程技术网

Flutter 颤振-将字符串变量转换为整数

Flutter 颤振-将字符串变量转换为整数,flutter,dart,Flutter,Dart,我想在无状态小部件中将字符串变量转换为整数 这是我的密码: final String bmiresult; Text( bmiresult, style: TextStyle( color: bmiresult > 30 ? Colors.red : Colors.green, fontSize: 40.0

我想在无状态小部件中将字符串变量转换为整数

这是我的密码:

final String bmiresult;

Text(
                      bmiresult,
                      style: TextStyle(
                        color: bmiresult > 30 ? Colors.red : Colors.green,
                        fontSize: 40.0,
                        fontWeight: FontWeight.bold,
                      ),
它表示未为字符串类型定义运算符>。


谢谢。

您可以使用int.parse,cf

最终字符串结果;
.
正文(
结果,,
样式:TextStyle(
颜色:int.parse(bmisresult)>30?颜色。红色:颜色。绿色,
字体大小:40.0,
fontWeight:fontWeight.bold,
),

谢谢@h1b9b。这很有效。很抱歉我问了一个非常简单的问题。请不要投反对票。