【发布时间】:2020-05-05 04:56:33
【问题描述】:
我想尝试定义以下公式来计算旧价格和新价格之间的计算并将其显示在文本小部件上,但是当我想在双变量中使用它时出现此错误:“只能访问静态成员初始化器" 这就是我想做的:
class ProductDetails extends StatefulWidget {
final prod_fullName;
final prod_pic;
final prod_old_price;
final prod_price;
double percent=(prod_old_price - prod_price)/prod_old_price*100;
ProductDetails({
this.prod_fullName,
this.prod_pic,
this.prod_old_price,
this.prod_price,
});
@override
_ProductDetailsState createState() => _ProductDetailsState();
}
class _ProductDetailsState extends State<ProductDetails> {
Row{
child:new Text("$percent%");
}
【问题讨论】:
标签: math flutter formula percentage discount