首页 > 解决方案 > 如何在颤动中绘制一个一侧为半圆的矩形?

问题描述

这就是我想要实现的目标(请原谅不完美,但你明白了):

我想画的形状

我看到一些使用 Clipper 的教程,但它们似乎没有达到我想要的效果,我需要使用容器来绘制它,因为我想在上面放置一些文本。

class DrawCustomCircle extends CustomClipper<Path> {
  @override
  Path getClip(Size size) {
    final Path path = new Path();
    ...
    return path;
  }
  @override
  bool shouldReclip(CustomClipper<Path> oldClipper) {
    return true;
  }

标签: flutterclip

解决方案


你可以BoxDecoration用来制作这个形状:

Container(
          height: 100,
          width: 200,
          decoration: BoxDecoration(
            color: Colors.blue,
            shape: BoxShape.rectangle,
            borderRadius: BorderRadius.horizontal(
              left: Radius.circular(50.0),
            ),
          ),
        ),

结果:

资源


推荐阅读