简体   繁体   English

如何在 flutter 中绘制一个边为半圆的矩形?

[英]How to draw a rectangle with one side as a half circle in flutter?

This is what I am trying to achieve (excuse the imperfection but you get the idea):这就是我想要实现的目标(请原谅不完美,但你明白了):

我想画的形状

I see some tutorials using clipper but they dont seem to achieve what I want, I need to use a container to draw this as I want to place some text over it.我看到一些使用 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;
  }

You can use BoxDecoration to make this shape:你可以使用BoxDecoration来制作这个形状:

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

Result:结果:

资源

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM