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之Radio

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

import 'package:flutter/material.dart';

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

class _RadioButtonDemoPageState extends State<RadioButtonDemoPage> {
  int groupValue = 1;
  String sGroupValue = '';

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: AppBar(
        title: Text('RadioButton Demo'),
      ),
      body: new Column(
        //mainAxisAlignment: MainAxisAlignment.center,
        children: <Widget>[
          new Radio(value: 0, groupValue: 0, onChanged: null),
          //onChanged为null表示按钮不可用
          new Radio(
              value: 1,
              groupValue: groupValue, //当value和groupValue一致的时候则选中
              activeColor: Colors.red,
              onChanged: (T) {
                updateGroupValue(T);
              }),
          new Radio(
              value: 2,
              groupValue: groupValue,
              onChanged: (T) {
                updateGroupValue(T);
              }),
          new Radio(
              value: 3,
              groupValue: groupValue,
              onChanged: (T) {
                updateGroupValue(T);
              }),
          new RadioListTile(
              value: 'Joe.Ye',
              groupValue: sGroupValue,
              title: new Text('Joe.Ye'),
              onChanged: (T) {
                updateStringGroupValue(T);
              }),
          new RadioListTile(
              value: 'Android',
              groupValue: sGroupValue,
              title: new Text('Android'),
              secondary: const Icon(Icons.favorite),
              onChanged: (T) {
                updateStringGroupValue(T);
              }),
          new RadioListTile(
              value: 'iOS',
              groupValue: sGroupValue,
              title: new Text('iOS'),
              onChanged: (T) {
                updateStringGroupValue(T);
              }),
        ],
      ),
    );
  }

  void updateGroupValue(int v) {
    setState(() {
      groupValue = v;
    });
  }

  void updateStringGroupValue(String v) {
    setState(() {
      sGroupValue = v;
    });
  }
}

Flutter Widget Radio

上一篇 Flutter Widget之Checkbox
下一篇 Flutter Widget之Switch