checkbox - 如何在 Flutter 中创建一个圆形的 CheckBox?或者改变CheckBox的样式,比如在Flutter中选中图片?

标签 checkbox flutter

我想创建一个像这样的圆形 CheckBox

enter image description here

我已经尝试了多种变体,但似乎都不起作用。包括我尝试使用 ClipRRect 。

由于代码比较多,这里只选取一部分展示

new Row(
      children: <Widget>[
        //new ClipRRect(
        // borderRadius: BorderRadius.all(Radius.circular(90.0)),
        //  child:
          new Checkbox(
              tristate: true,
              value: true,
              onChanged: (bool newValue){
                setState(() {

                });
              },
            activeColor: Color(0xff06bbfb),
          ),
       // ),

        new Expanded(
            child: new Text('将此手机号码和QQ号绑定,提高账号安全性。',
              style: new TextStyle(
                  color: Color(0xff797979)
              ),
            )
        ),

      ],
    ),

我是 Flutter 的新手。在此先致谢。

最佳答案

Material Design 复选框有一个 shape 属性,您可以为它设置 CircleBorder() 并且它会是圆的。

Checkbox(
      checkColor: Colors.white,
      fillColor: MaterialStateProperty.resolveWith(getColor),
      value: isChecked,
      shape: CircleBorder(),
      onChanged: (bool? value) {
        setState(() {
          isChecked = value!;
        });
      },
    );

关于checkbox - 如何在 Flutter 中创建一个圆形的 CheckBox?或者改变CheckBox的样式,比如在Flutter中选中图片?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52326268/

相关文章:

javascript - 复选框以 .detach 和 .prepend 对象

php - 如果数据在数据库中,则自动选中复选框

c# - 从数据网格中获取复选框的值?

dart - Flutter 从父类调用子类函数

flutter 错误 : W/IInputConnectionWrapper: getExtractedText on inactive InputConnection

php - 复杂的复选框形式

单击复选框时,jquery 验证错误消息不会消失

flutter - Flutter重用自定义小部件

Flutter:如何在文本字段文本中间插入文本

flutter - 如何快速复制并增加数量?