短视频系统,不改变背景颜色的基础上更改边框和字体颜色

短视频系统,不改变背景颜色的基础上更改边框和字体颜色实现的相关代码

代码如下:

 


class MyBody extends StatefulWidget {
  @override
  _MyBodyState createState() => _MyBodyState();
}
 
class _MyBodyState extends State<MyBody> {
  List<String> _tags = ['距离优先', '价格优先'];
  String _choice = '距离优先';
 
  @override
  Widget build(BuildContext context) {
    return Wrap(
      spacing: 8,
      children: _tags.map((tag) {
        return ChoiceChip(
          label: Text(tag),
          selected: _choice == tag,
          //选中
          backgroundColor: _choice == tag ? Colors.transparent : Colors.white,
          //背景颜色
          selectedColor: Colors.transparent,
          //选中时候的颜色
          shape: StadiumBorder(
            //边框
            side: BorderSide(
                width: 1,
                color: _choice == tag ? Color(0xff44c5fe) : Colors.grey,
                style: BorderStyle.solid),
          ),
          onSelected: (isSelected) {
            setState(() {
              _choice = tag;
              debugPrint('$_choice');
            });
          },
        );
      }).toList(),
    );
  }
}

以上就是短视频系统,不改变背景颜色的基础上更改边框和字体颜色实现的相关代码, 更多内容欢迎关注之后的文章 

 

上一篇:[Flutter-30] 子控件之间的相对布局01


下一篇:pytorch_函数