Flutter 如何用颤振制作小部件的一侧圆形边框?

Flutter 如何用颤振制作小部件的一侧圆形边框?,flutter,dart,border,Flutter,Dart,Border,我正在尝试用flutter中的容器小部件构建一侧的圆形边框。 我已经找过了,但找不到任何解决办法 容器( 宽度:150.0, 填充:常数边集全部(20.0), 装饰:盒子装饰( //边界半径:边界半径。圆形(30.0), /*边界:边界( 左:BorderSide() ),*/ 颜色:颜色。白色 ), 孩子:文本(“你好”), ), 您可以通过以下创建小部件的代码来实现这一点: return Container( width: 150.0, padding: const EdgeInse

我正在尝试用flutter中的容器小部件构建一侧的圆形边框。 我已经找过了,但找不到任何解决办法

容器(
宽度:150.0,
填充:常数边集全部(20.0),
装饰:盒子装饰(
//边界半径:边界半径。圆形(30.0),
/*边界:边界(
左:BorderSide()
),*/
颜色:颜色。白色
),
孩子:文本(“你好”),
),

您可以通过以下创建小部件的代码来实现这一点:

return Container(
  width: 150.0,
  padding: const EdgeInsets.all(20.0),
  decoration: BoxDecoration(
    shape: BoxShape.rectangle,
    color: Colors.white,
    borderRadius: BorderRadius.only(
      topLeft: Radius.circular(20.0),
      topRight: Radius.zero,
      bottomLeft: Radius.zero,
      bottomRight: Radius.zero,
    ),
  ),
  child: Text(
    "hello",
  ),
);

通过这种方式,您可以使容器小部件的左上角圆形边框处于颤振状态。

如果您希望容器的一侧圆化,则需要使用
边框半径。仅使用
并指定要圆化的角点,如下所示:

Container(
          width: 150.0,
          padding: const EdgeInsets.all(20.0),
          decoration: BoxDecoration(
              borderRadius: BorderRadius.only(
                  topRight: Radius.circular(40.0),
                  bottomRight: Radius.circular(40.0)),
              color: Colors.white),
          child: Text("hello"),
        ),

使用
边界半径。仅使用
并提供侧面

return Center(
  child: Container(
    height: 100,
    width: 100,
    decoration: BoxDecoration(
      borderRadius: BorderRadius.only(
        topRight: Radius.circular(40),
      ),
      border: Border.all(
        width: 3,
        color: Colors.green,
        style: BorderStyle.solid,
      ),
    ),
    child: Center(
      child: Text(
        "Hello",
      ),
    ),
  ),
);
输出


另一种方法是使用ClipRRect小部件。 只需使用ClipRRect包装小部件并给出半径。 您可以指定要使哪个角圆。

ClipRRect(
      borderRadius: BorderRadius.only(topRight: Radius.circular(10)),
      child: Container(
        height: 40,
        width: 40,
        color: Colors.amber,
        child: Text('Hello World!'),
      ),
    );

也可以这样做,

 borderRadius: new BorderRadius.only(
     topLeft: const Radius.circular(30.0),
     bottomLeft: const Radius.circular(30.0),
 ),

不幸的是,到目前为止,您还不能只塑造容器的一面,但类似类型的功能可以通过使该面的两个角都具有圆形半径来实现。有一种方法可以做到这一点吗?仅使用ShapeOrder实现?尝试添加代码的输出。查看您的答案和另一个投票率最高的答案之间的差异,主要差异是输出屏幕截图。