簡體   English   中英

如何在 flutter 中繪制一個邊為半圓的矩形?

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

這就是我想要實現的目標(請原諒不完美,但你明白了):

我想畫的形狀

我看到一些使用 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;
  }

你可以使用BoxDecoration來制作這個形狀:

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

結果:

資源

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM