我正在按API-doc的方式调用函数drawPoints,如下所示

      final paint = new Paint()
       ..color = Colors.blue[400]
       ..strokeCap = StrokeCap.round;
     var offsetList = [new Offset(2.0, 5.0), new Offset(50.0, 100.0)];
     canvas.drawPoints(const PointMode(1), offsetList, paint);

当我将const PointMode(1)传递到canvas.drawPoints时,它将引发编译器错误。将PointMode传递到此函数的正确方法是什么?

最佳答案

PointMode是一个枚举,您不能实例化它。您可以从here检查所有可用的PointMode。

要在drawPoints方法中指定PointMode,只需更改

canvas.drawPoints(const PointMode(1), offsetList, paint);


canvas.drawPoints(PointMode.points, offsetList, paint);

10-06 11:22