简体   繁体   English

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

[英]How to change the shape of chip in flutter

I am trying to create a shape which is something similar as shown in the following Image. 我正在尝试创建一个类似于下图所示的形状。

在此处输入图片说明

I am planning to use Chips for achieving the same. 我打算使用Chips来实现相同的目的。 However, chips have a rounded border on all the 4 sides. 但是,芯片的所有四个侧面都具有圆形边界。 is there any way I can override this and have a rectangular corner on the left side and rounded corner in the right side. 有什么办法可以覆盖它,并在左侧具有矩形角,在右侧具有圆角。

You can use shape property of the Chip widget. 您可以使用Chip小部件的shape属性。 In that property you can pass RoundedRectangleBorder() and mention borderRadius inside of the RoundedRectangleBorder(). 在该属性中,您可以传递RoundedRectangleBorder()并在RoundedRectangleBorder()内部提及borderRadius。 There are other ShapeBorders like BeveledRectangleBorder(), StadiumBorder(),OutlineInputBorder(),ContinuousRectangleBorder() and so on. 还有其他ShapeBorder,例如BeveledRectangleBorder(),StadiumBorder(),OutlineInputBorder(),ContinuousRectangleBorder()等。

A code is given below using RoundedRectangleBorder(): 下面使用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)
          ),
        )
      );

在此处输入图片说明

Hope this helps you out!! 希望这可以帮助你!!

I had to place the chip inside a container then match the background colours. 我必须将芯片放入容器中,然后匹配背景色。

  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)),      
    ),
  );

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

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