Notice: 函数 WP_Scripts::localize 的调用方法不正确$l10n 参数必须是一个数组。若要将任意数据传递给脚本,请改用 wp_add_inline_script() 函数。 请查阅调试 WordPress来获取更多信息。 (这个消息是在 5.7.0 版本添加的。) in /data/www/appblog/wp-includes/functions.php on line 6131

Flutter Widget之Checkbox

Widget:https://flutter.io/docs/development/ui/widgets
Checkbox:https://docs.flutter.io/flutter/material/Checkbox-class.html
     

import 'package:flutter/material.dart';

class CheckBoxDemoPage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return new _CheckBoxDemoPageState();
  }
}

class _CheckBoxDemoPageState extends State<CheckBoxDemoPage> {
  bool isCheck = false;
  List<bool> isChecks = [false, false];

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: AppBar(
        title: Text('CheckBox Demo'),
      ),
      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('Joe.Ye'),
                controlAffinity: ListTileControlAffinity.platform,
                //控制亲和度: leading按钮显示在文字前面, trailing按钮显示在文字的后面, platform显示样式根据手机当前平台默认显示
                onChanged: (bool) {
                  setState(() {
                    isCheck = bool;
                  });
                }),
          ),
          new Center(
            child: new CheckboxListTile(
                value: isCheck,
                title: new Text('Joe.Ye'),
                secondary: const Icon(Icons.access_alarm),
                controlAffinity: ListTileControlAffinity.platform,
                onChanged: (bool) {
                  setState(() {
                    isCheck = bool;
                  });
                }),
          ),
          new Center(
            child: new CheckboxListTile(
                value: isCheck,
                title: new Text('Joe.Ye'),
                controlAffinity: ListTileControlAffinity.leading,
                onChanged: (bool) {
                  setState(() {
                    isCheck = bool;
                  });
                }),
          ),
          new Center(
            child: new CheckboxListTile(
                value: isCheck,
                title: new Text('AppBlog.CN'),
                controlAffinity: ListTileControlAffinity.trailing,
                onChanged: (bool) {
                  setState(() {
                    isCheck = bool;
                  });
                }),
          ),
          new Center(
            child: new CheckboxListTile(
                value: isCheck,
                title: new Text('http://www.appblog.cn'),
                controlAffinity: ListTileControlAffinity.platform,
                onChanged: (bool) {
                  setState(() {
                    isCheck = bool;
                  });
                }),
          ),
          new Center(
            child: new CheckboxListTile(
                value: isChecks[0],
                title: new Text('Android'),
                controlAffinity: ListTileControlAffinity.platform,
                onChanged: (bool) {
                  setState(() {
                    isChecks[0] = bool;
                  });
                }),
          ),
          new Center(
            child: new CheckboxListTile(
                value: isChecks[1],
                title: new Text('iOS'),
                controlAffinity: ListTileControlAffinity.platform,
                onChanged: (bool) {
                  setState(() {
                    isChecks[1] = bool;
                  });
                }),
          )
        ],
      )
    );
  }
}

Flutter Widget Checkbox

上一篇 Flutter Widget之TextField
下一篇 Flutter Widget之Radio