【发布时间】:2021-06-13 08:43:03
【问题描述】:
我有一个钱包圈,它可以响应已完成的付款。我的问题是当钱包金额为零时,我希望绘制圆圈的小部件不可见。
我现在所做的是,我使用三元运算符在 Custompaint Widget 中检查它。我错过了什么?
CustomPaint(
painter: (this.total <= 0)
? CurvePainter(colors: [
// To test if the color changes
Colors.red.withOpacity(0.9),
Colors.red.withOpacity(0.9)
], angle: 0, strokeWidth: 0)
: CurvePainter(
colors: [
Colors.white.withOpacity(0.9),
Colors.white.withOpacity(0.9),
],
angle: 360 - ((this.used / this.total) * 360),
strokeWidth: this.strokeWidth,
),
size: Size.fromRadius(strokeWidth),
child: SizedBox(
width: this.radius,
height: this.radius,
),
)
【问题讨论】:
标签: flutter conditional-statements flutter-widget