我有一个简单的 CustomPaint/CustomPainter 可以绘制一段圆(下面的代码)。我读过我不能使用 GestureDetector 因为它不是一个合适的小部件,那么获取输入的最佳方式是什么?
我将有一堆片段放在一起,所以我需要像素精确的触摸位置。
我想到了两种可能:
我的自定义画家:
class _SegmentPainter extends CustomPainter {
static const offset = -pi/2;
double start;
double end;
double innerRadius;
double outerRadius;
Color color;
_SegmentPainter(this.start, this.end, {this.innerRadius = 0.0, this.outerRadius, this.color});
@override bool shouldRepaint(CustomPainter oldDelegate) => this == oldDelegate;
@override bool shouldRebuildSemantics(CustomPainter oldDelegate) => this == oldDelegate;
@override
void paint(Canvas canvas, Size size) {
Path path = new Path();
path.arcTo(Rect.fromCircle(center: new Offset(0.0, 0.0), radius: outerRadius), offset + start, end-start, …Run Code Online (Sandbox Code Playgroud) 如何使用activeThumbImage属性为颤动中的切换按钮设置图像?我对如何为此属性设置ImageProvider值感到有些困惑?我是否可以看一下实现Switch小部件的activeThumbImage属性的示例?