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

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. react-navigation 做导航栏,发现 Android 上的标题不居中

    在做 React Native 应用的时候,我们常常使用 react-navigation 做导航栏,发现 Android 上的标题不居中,IOS 上没问题. 1 如果只有标题,那就在 headerT ...

  2. 基于ATtiny85轻松制作一款智能手表

    这是基于ATtiny85系列的简约手表系列中的第三款.该款手表通过在微型64x48 OLED显示屏上绘制模拟的手表来显示时间.它使用独立的晶振控制的低功耗RTC芯片来保持每月几秒钟的时间,并在不显示时 ...

  3. JVM中对象是否已死

  4. ifram 调用父页面的easyui弹框

    转自https://www.cnblogs.com/puke/archive/2012/09/13/2683067.html 曾经试过这样的方法       在iframe子页面获取父页面元素     ...

  5. 题解 洛谷P4302 【[SCOI2003]字符串折叠】

    一眼区间\(dp\),但蒟蒻的我还是调了好久\(qwq\) [状态设置] 设\(f[i][j]\)为子串\([i,j]\)的最短折叠 最后答案为\(f[1][n]\) 废话 [初始化] \(1\) 首 ...

  6. Keras神经网络data generators解决数据内存

    在使用kears训练model的时候,一般会将所有的训练数据加载到内存中,然后喂给网络,但当内存有限,且数据量过大时,此方法则不再可用.此博客,将介绍如何在多核(多线程)上实时的生成数据,并立即的送入 ...

  7. Eclipse中安装Spring IDE

    ====>在线安装 1.寻找Spring IDE插件更新地址:http://marketplace.eclipse.org/content/spring-ide 2.复制对应Eclipse版本的 ...

  8. LightOJ - 1236 - Pairs Forming LCM(唯一分解定理)

    链接: https://vjudge.net/problem/LightOJ-1236 题意: Find the result of the following code: long long pai ...

  9. LightOJ - 1259 - Goldbach`s Conjecture(整数分解定理)

    链接: https://vjudge.net/problem/LightOJ-1259 题意: Goldbach's conjecture is one of the oldest unsolved ...

  10. C 语言程序设计

    C 语言数据类型: 整数: char(也是字符型) short int long 浮点型: float double 指针 自定义类型 输入输出格式化: int ->%d long ->% ...