仅在圆内绘制圆角矩形的边框

时间:2021-06-07 04:28:40

标签: flutter dart flutter-layout

我正在使用 extended_image 库来允许用户裁剪他们的图像。我有一个显示裁剪选项的列表视图(即 4:3、3:4、16:9 等)。我已经使用 Painter 成功创建了列表视图的每个项目。

enter image description here

如您所见,在圆圈中绘制了纵横比。虽然这很棒,但我只想要这些圆角矩形的轮廓,而不是填充。那么我如何获得边界?

我的代码:

final Path path = Path();
    path.fillType = PathFillType.evenOdd;
    path.addOval(
      Rect.fromCircle(
        center: Offset(43, 30),
        radius: 30.0,
      ),
    );
    path.addRRect(
      RRect.fromRectAndRadius(
        getDestinationRect(
          rect: const EdgeInsets.only(
            top: 15.0,
            bottom: 30.0,
            left: 30.0,
            right: 30.0,
          ).deflateRect(rect),
          inputSize: Size(aspectRatioResult * 100, 100),
          fit: BoxFit.contain,
        ),
        Radius.circular(2.0),
      ),
    );
    canvas.drawPath(path, paint);

0 个答案:

没有答案