单选框,允许用户从一组中选择一个选项。

import 'package:flutter/material.dart';

class RadioDemo extends StatefulWidget {
@override
_RadioDemoState createState() => _RadioDemoState();
} class _RadioDemoState extends State<RadioDemo> {
int _radioGroupA = 0; void _handleRadioValueChanged(int value) {
setState(() {
_radioGroupA = value;
});
} @override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('RadioDemo'),
elevation: 0.0,
),
body: Container(
padding: EdgeInsets.all(16.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text('RadioGroupValue: $_radioGroupA'),
SizedBox(height: 32.0),
RadioListTile(
value: 0,
groupValue: _radioGroupA,
onChanged: _handleRadioValueChanged,
title: Text('Options A'),
subtitle: Text('Description'),
secondary: Icon(Icons.filter_1),
selected: _radioGroupA == 0,
),
RadioListTile(
value: 1,
groupValue: _radioGroupA,
onChanged: _handleRadioValueChanged,
title: Text('Options B'),
subtitle: Text('Description'),
secondary: Icon(Icons.filter_2),
selected: _radioGroupA == 1,
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
// Radio(
// value: 0,
// groupValue: _radioGroupA,
// onChanged: _handleRadioValueChanged,
// activeColor: Colors.black,
// ),
// Radio(
// value: 1,
// groupValue: _radioGroupA,
// onChanged: _handleRadioValueChanged,
// activeColor: Colors.black,
// ),
],
),
],
),
)
);
}
}

文档:https://api.flutter.dev/flutter/material/Radio-class.html

效果:

flutter Radio单选框的更多相关文章

  1. TagHelper+Layui封装组件之Radio单选框

    TagHelper+Layui封装组件之Radio单选框 标签名称:cl-radio 标签属性: asp-for:绑定的字段,必须指定 asp-items:绑定单选项 类型为:IEnumerable& ...

  2. 前端 HTML form表单标签 input标签 type属性 radio 单选框

    <input type="radio"> 单选框 适用于 选择性别按钮网页等 <!DOCTYPE html> <html lang="en& ...

  3. 纯css3简单实用的checkbox复选框和radio单选框

    昨天为大家分享了一款很炫的checkbox复选框和radio单选框,今天再给大家带来一款简单实用的checkbox复选框和radio单选框.界面清淅.舒服.先给大家来张效果图: 在线预览   源码下载 ...

  4. 纯css3实现的超炫checkbox复选框和radio单选框

    之前为大家分享了好多css3实现的按钮.今天要为大家分享的是纯css3实现的checkbox复选框和radio单选框,效果超级炫.先让我们看看图吧! 在线预览   源码下载 这个实例完全由css3实现 ...

  5. elementUI 学习入门之 radio 单选框

    Radio 单选框 基础用法 选项默认可见,选项不宜过多,选项过多建议使用 select 选择器 使用 Radio 组件,需要设置 v-model 绑定变量,选中意味着变量的值为相应 Radio  l ...

  6. layui 获取radio单选框选中的值

    Layui 获取 radio的值,layui判断radio选中的单选值 layui form 表单获取radio选中的值 首先准备两个radio <input type="radio& ...

  7. selenium死活定位不到元素以及radio单选框点击不生效

    今天操作一个单选框浪费太多时间,现在其实很简单得东西,记录一下: 1,问题一,定位不到 如图,使用selenium IDE和xpath helper都试过,无法成功定位到这个单选框,实际上是因为,这个 ...

  8. Radio 单选框

    Radio 单选框 在一组备选项中进行单选 ¶基础用法 由于选项默认可见,不宜过多,若选项过多,建议使用 Select 选择器. 要使用 Radio 组件,只需要设置v-model绑定变量,选中意味着 ...

  9. JQuery radio单选框应用

    转载:JQuery判断radio(单选框)是否选中和获取选中值方法总结 一.利用获取选中值判断选中 直接上代码,别忘记引用JQuery包 复制代码 代码如下: < !DOCTYPE html P ...

随机推荐

  1. 清除PLSQL Developer访问数据库连接的历史记录

    1.C盘下 路径: C:\Users\JourneyOfFlower\AppData\Roaming\PLSQL Developer 12\Preferences\JourneyOfFlower\ J ...

  2. jupytext library using in jupyter notebook

    目录 1. jupytext features 2. Way of using 3. usage 4. installation 1. jupytext features Jupytext can s ...

  3. LG4762 Virus synthesis

    Virus synthesis 初始有一个空串,利用下面的操作构造给定串 S . 串开头或末尾加一个字符 串开头或末尾加一个该串的逆串 求最小化操作数, ∣S∣≤105 . 题解 显然应该多使用操作2 ...

  4. java8中的流操作

    https://www.ibm.com/developerworks/cn/java/j-experience-stream/index.html Stream 流是 Java 8 新提供给开发者的一 ...

  5. git 删除错误commit

    其实就是硬reset到之前对的commit记录然后强行再推送到远程库一下 具体操作: git reset --hard <commit_id> git push origin HEAD - ...

  6. Java - MyBites 逆向工程

    逆向工程是什么呢? 说白了就是 mybatis 中提供了一个可以让你从 已经创建好的 数据库中,去通过表名,生成对应类,类属性和XML文件(sql语句). 源码:mybatis_AutoGenerat ...

  7. MySQL Create table as / Create table like

    a.create table like方式会完整地克隆表结构,但不会插入数据,需要单独使用insert into或load data方式加载数据 b.create table as  方式会部分克隆表 ...

  8. Kafka 基础操作

    cd /root/kafka/kafka_2.10-0.8.2.2/bin 1.查看kafka topic kafka-topics.sh --list --zookeeper 172.16.100. ...

  9. Greenplum 添加mirror步骤

    原文链接:https://yq.aliyun.com/articles/695864 [TOC] 概述 新安装的greenplum集群只有primary节点,没有mirror.高可用性没得到保证.所以 ...

  10. js实现大文件上传分片上传断点续传

    文件夹上传:从前端到后端 文件上传是 Web 开发肯定会碰到的问题,而文件夹上传则更加难缠.网上关于文件夹上传的资料多集中在前端,缺少对于后端的关注,然后讲某个后端框架文件上传的文章又不会涉及文件夹. ...