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。这很有效。很抱歉我问了一个非常简单的问题。请不要投反对票。