如何在颤振中改变切屑的形状

时间:2018-09-18 06:14:28

标签: android flutter

我正在尝试创建一个类似于下图所示的形状。

enter image description here

我打算使用Chips来实现相同目的。但是,芯片的所有四个侧面都具有圆形边界。有什么办法可以覆盖它,并在左侧具有矩形角,在右侧具有圆角。

2 个答案:

答案 0 :(得分:1)

您可以使用Chip小部件的shape属性。 在该属性中,您可以传递RoundedRectangleBorder()并在RoundedRectangleBorder()内部提及borderRadius。还有其他ShapeBorder,例如BeveledRectangleBorder(),StadiumBorder(),OutlineInputBorder(),ContinuousRectangleBorder()等。

下面使用RoundedRectangleBorder()给出代码:

    Chip(
      backgroundColor: Color(0xFFE1E4F3),
      padding: const EdgeInsets.symmetric(vertical: 15,horizontal: 5),
      shape: RoundedRectangleBorder(borderRadius: BorderRadius.only(topRight: Radius.circular(20),bottomRight: Radius.circular(20))),
      label: Text("Custom Chip Shape",
        style: TextStyle(
          fontSize: 16,
          fontWeight: FontWeight.w600,
          color: Color(0xFF3649AE)
          ),
        )
      );

enter image description here

希望这可以帮助您!

答案 1 :(得分:0)

我不得不将芯片放在容器中,然后匹配背景色。

  new Container(
    decoration: new BoxDecoration(
      color: Colors.blue.shade100,
      borderRadius: new BorderRadius.only(
          topRight: Radius.circular(30.0), bottomRight: Radius.circular(30.0)),
      border: new Border.all(color: Color.fromRGBO(0, 0, 0, 0.0)),
    ),
    child: new Chip(
      label: new Text('Order Created',
          style: new TextStyle(fontSize: 20.0, color: Colors.blueGrey)),      
    ),
  );