【发布时间】:2022-07-26 14:47:10
【问题描述】:
我正在尝试进行计算。但我的价值来自int?,它不允许我这样做。错误是The argument type 'int?' can't be assigned to the parameter type 'num'. 我不明白。
这是我的代码:
String goal= "1000";
String workout = "0";
String remaining = "";
int? _total;
@override
void initState() {
super.initState();
dbHelper = DbHelper();
_calcTotal();
}
void _calcTotal() async{
var total = (await dbHelper.calcTotal())[0]['total'];
print(total);
setState(() => _total = total);
}
int resulttext = int.parse(goal) - _total + int.parse(workout);
remaining = resulttext.toString();
【问题讨论】:
标签: flutter