• flutter控件之CheckBox


    import 'package:flutter/material.dart';
    class LearnCheckBox extends StatefulWidget{
      @override
      State<StatefulWidget> createState() {
        return new _LearnCheckBox();
      }
    }
    class _LearnCheckBox extends State<LearnCheckBox>{
      bool isCheck=false;
      List<bool> isChecks=[false,false];
      @override
      Widget build(BuildContext context) {
        return new Scaffold(
          body:new Column(
            mainAxisAlignment: MainAxisAlignment.start,
            children: <Widget>[
              new Center(
                child: new Checkbox(
                  value: isCheck,
                  activeColor: Colors.red,
                  onChanged: (bool){
                    setState(() {
                      isCheck=bool;
                    });
                  },
                ),
              ),
              new Center(
                child: new CheckboxListTile(
                    value: isCheck,
                    title: new Text('张晓'),
                    controlAffinity: ListTileControlAffinity.platform,//控制亲和度  leading按钮显示在文字前面  trailing按钮显示在文字的后面   platform显示样式根据手机当前平台默认显示
                    onChanged: (bool){
                      setState(() {
                        isCheck=bool;
                      });
                    }),
              ),
              new Center(
                child: new CheckboxListTile(
                    value: isCheck,
                    title: new Text('张晓'),
                    controlAffinity: ListTileControlAffinity.platform,
                    onChanged: (bool){
                      setState(() {
                        isCheck=bool;
                      });
                    }),
              ),
              new Center(
                child: new CheckboxListTile(
                    value: isCheck,
                    title: new Text('张晓'),
                    controlAffinity: ListTileControlAffinity.platform,
                    onChanged: (bool){
                      setState(() {
                        isCheck=bool;
                      });
                    }),
              ),
              new Center(
                child: new CheckboxListTile(
                    value: isCheck,
                    title: new Text('张晓'),
                    controlAffinity: ListTileControlAffinity.platform,
                    onChanged: (bool){
                      setState(() {
                        isCheck=bool;
                      });
                    }),
              ),
              new Center(
                child: new CheckboxListTile(
                    value: isCheck,
                    title: new Text('张晓'),
                    controlAffinity: ListTileControlAffinity.platform,
                    onChanged: (bool){
                      setState(() {
                        isCheck=bool;
                      });
                    }),
              ),
              new Center(
                child: new CheckboxListTile(
                    value: isChecks[0],
                    title: new Text('张晓'),
                    controlAffinity: ListTileControlAffinity.platform,
                    onChanged: (bool){
                      setState(() {
                        isChecks[0]=bool;
                      });
                    }),
              ),
              new Center(
                child: new CheckboxListTile(
                    value: isChecks[1],
                    title: new Text('张晓'),
                    controlAffinity: ListTileControlAffinity.platform,
                    onChanged: (bool){
                      setState(() {
                        isChecks[1]=bool;
                      });
                    }),
              )
            ],
          )
        );
      }
    }
  • 相关阅读:
    利用反射获取类的所有字段
    System.Data.Entity.Internal.AppConfig 类型初始值设定项引发异常
    sql server 修改列类型
    sql server 删除表字段和字段的约束
    sql server 查找字段上的约束
    ASP.NET MVC自定义路由
    初探pandas——索引和查询数据
    初探pandas——安装和了解pandas数据结构
    初探numpy——numpy常用通用函数
    初探numpy——广播和数组操作函数
  • 原文地址:https://www.cnblogs.com/zhujiabin/p/10147735.html
Copyright © 2020-2023  润新知