如何改变颤振中的芯片形状

问题描述 投票:0回答:1

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

enter image description here

我打算用Chips来实现同样的目标。但是,芯片的所有4个边都有圆形边框。有什么方法可以覆盖它,左侧有一个矩形角,右侧有一个圆角。

android flutter
1个回答
1
投票

您可以使用Chip小部件的shape属性。在该属性中,您可以传递RoundedRectangleBorder()并在RoundedRectangleBorder()中提及borderRadius。还有其他ShapeBorders,如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

希望这可以帮助你!!


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)),      
    ),
  );
© www.soinside.com 2019 - 2024. All rights reserved.