博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
flutter控件之RadioButton
阅读量:4309 次
发布时间:2019-06-06

本文共 2606 字,大约阅读时间需要 8 分钟。

import 'package:flutter/material.dart';class LearnRadioButton extends StatefulWidget{  @override  State
createState() { return new _LearnRadioButton(); }}class _LearnRadioButton extends State
{ int groupValue=1; @override Widget build(BuildContext context) { return new Scaffold( body: new Column( mainAxisAlignment: MainAxisAlignment.center, children:
[ 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 Radio( value: 4, groupValue: groupValue, onChanged: (T){ updateGroupValue(T); } ), new Radio( value: 5, groupValue: groupValue, onChanged: (T){ updateGroupValue(T); } ), new Radio( value: 6, groupValue: groupValue, onChanged: (T){ updateGroupValue(T); } ), new RadioListTile( value: 7, groupValue: groupValue, title: new Text('小张'), onChanged: (T){ updateGroupValue(T); }), new RadioListTile( value: 8, groupValue: groupValue, title: new Text('小林'), onChanged: (T){ updateGroupValue(T); }), new RadioListTile( value: 9, groupValue: groupValue, title: new Text('小王'), onChanged: (T){ updateGroupValue(T); }), new RadioListTile( value: 10, groupValue: groupValue, title: new Text('小红'), onChanged: (T){ updateGroupValue(T); }) ], ), ); } void updateGroupValue(int v){ setState(() { groupValue=v; }); }}

 

转载于:https://www.cnblogs.com/zhujiabin/p/10144588.html

你可能感兴趣的文章
iOS 如何放大按钮点击热区
查看>>
ios设备唯一标识获取策略
查看>>
获取推送通知的DeviceToken
查看>>
Could not find a storyboard named 'Main' in bundle NSBundle
查看>>
CocoaPods安装和使用教程
查看>>
Beginning Auto Layout Tutorial
查看>>
block使用小结、在arc中使用block、如何防止循环引用
查看>>
iPhone开发学习笔记002——Xib设计UITableViewCell然后动态加载
查看>>
iOS开发中遇到的问题整理 (一)
查看>>
Swift code into Object-C 出现 ***-swift have not found this file 的问题
查看>>
为什么你的App介绍写得像一坨翔?
查看>>
RTImageAssets插件--@3x可自动生成@2x图片
查看>>
iOS开发的一些奇巧淫技
查看>>
linux的挂载的问题,重启后就挂载就没有了
查看>>
docker原始镜像启动容器并创建Apache服务器实现反向代理
查看>>
docker容器秒死的解决办法
查看>>
管理网&业务网的一些笔记
查看>>
openstack报错解决一
查看>>
openstack报错解决二
查看>>
linux source命令
查看>>