如何在Flutter中实现CheckBox [英] how to implement checkBox in flutter

查看:420
本文介绍了如何在Flutter中实现CheckBox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在这里,我提到了我的复选框代码.我是新手,所以为了记住我的功能,我必须实现它.

Here I have mentioned my code of checkbox. I am new to flutter, So I have to implement it for Remember me functionality.

代码:

 Container(
 padding: EdgeInsets.all(10.0),
  child: Column(
    children: <Widget>[
     new Checkbox(value: checkBoxValue,
          activeColor: Colors.green,
          onChanged:(bool newValue){
        setState(() {
          checkBoxValue = newValue;
        });
       Text('Remember me');
          }),
    ],
  ),
);

推荐答案

如果您需要带有标签的复选框,则可以使用CheckboxListTile

If you need a Checkbox with a label then you can use a CheckboxListTile

CheckboxListTile(
    title: Text("title text"),
    value: checkedValue,
    onChanged: (newValue) { 
                 setState(() {
                   checkedValue = newValue; 
                 }); 
               },
    controlAffinity: ListTileControlAffinity.leading,  //  <-- leading Checkbox
  )

这篇关于如何在Flutter中实现CheckBox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆