当前位置:网站首页>Shutter start from zero 006 radio switches and checkboxes
Shutter start from zero 006 radio switches and checkboxes
2022-06-30 12:02:00 【Hua Weiyun】
In the usual project preparation work , We use radio switches and checkboxes more often , Let's briefly introduce the principle of radio switch and check box today , Later, we will introduce the customization and encapsulation of radio switches and check boxes in detail .
Material Component library provides Material Style radio switch Switch And check boxes Checkbox, Although they are all inherited from StatefulWidget, But they themselves don't save the currently selected state , The selected state is managed by the parent component . When Switch or Checkbox When clicked , It will trigger them onChanged Callback , We can handle the selected state change logic in this callback . Here's a simple example
class _MyHomePageState extends State<MyHomePage> { bool _swithSelected = true; // The status of the radio switch , We select by default bool _checkBoxSelected = true; // Check box status , We select by default @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text(widget.title), ), body: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center, children: [ Switch( value: _swithSelected, // current state onChanged: (value) { // State monitoring , Rebuild status setState(() { _swithSelected = value; }); }, ), Checkbox( value: _checkBoxSelected, activeColor: Colors.blue, // Color when selected onChanged: (value) { setState(() { _checkBoxSelected = value!; }); }, ), ], )); }} The operation effect is shown below 
In the next section, we will solve Input box and form
边栏推荐
- nvm安装node后,在使用npm指令时候显示不是内部或外部指令
- A Generic Deep-Learning-Based Approach for Automated Surface Inspection-论文阅读笔记
- Le talent scientifique 丨 dessins animés qu'est - ce qu'erdma?
- R语言ggplot2可视化:gganimate包基于transition_time函数创建动态散点图动画(gif)
- MySQL 复合查询
- 重新理解oauth2.0协议进行联合登录
- 治数如治水,数据治理和数据创新难在哪?
- What is the function of LED backlight?
- 60 个神级 VS Code 插件!!
- wallys/3 × 3 MIMO 802.11ac Mini PCIe Wi-Fi Module, QCA9880, 2,4GHz / 5GHzDesigned for Enterprise
猜你喜欢

A quietly rising domestic software, low-key and powerful!

来聊聊怎么做硬件兼容性检测,快速迁移到openEuler?

服务器常用的一些硬件信息(不断更新)

Who still remembers "classmate Zhang"?

What is the function of LED backlight?

Evaluation of IP location query interface Ⅲ

麒麟软件韩乃平:数字中国建设需要自己的开源根社区

Boost study: boost log

科普達人丨漫畫圖解什麼是eRDMA?

Le talent scientifique 丨 dessins animés qu'est - ce qu'erdma?
随机推荐
R language ggplot2 visualization: gganimate package is based on Transition_ The time function creates a dynamic scatter graph animation (GIF), and uses the labs function to add a dynamic time title to
Who still remembers "classmate Zhang"?
Typescript readonlyarray (read only array type) details
Object mapping - mapping Mapster
用宝塔建第2个网站时网站总是报错:No input file specified.
这些电影中的科幻构想,已经用AI实现了
DMA控制器8237A
他是上海两大产业的第一功臣,却在遗憾中默默离世
wallys/3×3 MIMO 802.11ac Mini PCIe Wi-Fi Module, QCA9880, 2,4GHz / 5GHzDesigned for Enterprise
The sci-fi ideas in these movies have been realized by AI
Learn how to implement distributed locks in redis - my own understanding
Database connection pool Druid
R language ggplot2 visualization: use ggplot2 to visualize the scatter diagram and use scale_ color_ viridis_ D function specifies the color scheme of data points
OpenMLDB Meetup No.4 会议纪要
R language ggplot2 visualization: use ggplot2 visualization scatter diagram and the size parameter in AES function to specify the size of data points (point size)
【重温经典C语言】~c语言中%x、%c、%d、%x等等等、c语言取地址符&的作用、C语言中的 联合体
60 divine vs Code plug-ins!!
TypeScript ReadonlyArray(只读数组类型) 详细介绍
If it is not listed again, Kuangshi technology will not be able to endure
R language ggplot2 visualization: use ggplot2 visualization scatter diagram and the color parameter in AES function to specify that data points in different groups are displayed in different colors