美文网首页flutter
Flutter之Radio组件

Flutter之Radio组件

作者: 习惯了_就好 | 来源:发表于2019-04-23 16:17 被阅读0次
    /**
     * 单选框 点自己不能取消
     *const Radio({
        Key key,
        //groupValue 与 value 相等时 Radio 被选中
        @required this.value,//value 是当前Radio 的值
        @required this.groupValue,//groupValue 是组的值
        @required this.onChanged,
        this.activeColor,//选中时的颜色
        this.materialTapTargetSize,//点击区域尺寸,padded:向四周扩展48px区域;shrinkWrap:控件区域
        })
     */
    
    /**
     * 系统封装的一个Radio
     *
        const RadioListTile({
        Key key,
        @required this.value,
        @required this.groupValue,
        @required this.onChanged,
        this.activeColor,//选中颜色
        this.title,
        this.subtitle,
        this.isThreeLine = false,//设置为true,高度变大
        this.dense,
        this.secondary,//左侧图标
        this.selected = false,
        this.controlAffinity = ListTileControlAffinity.platform,//leading:secondary在右侧;trailing:secondary在左侧;platform:根据平台确定
        })
     */
    
    
    body: Column(
              children: <Widget>[
                Radio(
                  value: "aaa",
                  groupValue: groupValue,
                  onChanged: (result) {
                    setState(() {
                      groupValue = result;
                    });
                  },
                  activeColor: Colors.red,
                  materialTapTargetSize: MaterialTapTargetSize.padded,
                ),
                Radio(
                  value: "bbb",
                  groupValue: groupValue,
                  onChanged: (result) {
                    setState(() {
                      groupValue = result;
                    });
                  },
                  activeColor: Colors.red,
                  materialTapTargetSize: MaterialTapTargetSize.padded,
                ),
    
                RadioListTile(
                  value: "ccc",
                  groupValue: groupValue,
                  onChanged: (result) {
                    setState(() {
                      groupValue = result;
                    });
                  },
                  activeColor: Colors.red,
                  title: Text("标题"),
                  subtitle: Text("副标题副标题副标题副标题副标题副标题副标题副标题副标题"),
                    isThreeLine: false,
                  secondary: Icon(Icons.alarm),
    //                selected:true
                controlAffinity: ListTileControlAffinity.trailing,
                )
              ],
            ),
    

    相关文章

      网友评论

        本文标题:Flutter之Radio组件

        本文链接:https://www.haomeiwen.com/subject/vjliwqtx.html