当前位置:网站首页>Flutter 从零开始 004 按钮组件
Flutter 从零开始 004 按钮组件
2022-06-30 10:46:00 【华为云】
1、按钮
Material 组件库中,为我们提供了多种按钮组件,
如 ElevatedButton 、TextButton 、 OutlinedButton 等
另外,Material 库中所有的按钮组件都有一个相同的特性,那就是水波纹动画效果,还有一个onPressed 属性,用来设置按钮的点击回调。
ElevatedButton 即漂浮按钮,它带有阴影和灰色的背景,按下后,阴影会变大,如下图
ElevatedButton 按钮的使用非常的简单
ElevatedButton( onPressed: () {}, child: Text("ElevatedButton"), ),TextButton 即文本按钮,默认背景透明,并不带阴影,按下的时候,会有一个背景色,如下图
TextButton 的使用也非常的简单
TextButton( onPressed: (){}, child: Text("TextButton"), )OutlinedButton 默认会有一个边框,不带阴影且背景透明。按下后,边框的颜色会变亮、同时会出现背景和阴影效果,如下图

OutlinedButton 的使用也非常的简单
OutlinedButton( onPressed: () {}, child: Text("OutlinedButton"), )IconButton 是一个图标按钮,可以生成一个可电影的icon ,不包括文字,没有默认背景,点击后会出现背景动画,如下图
IconButton 的使用也非常的简单
IconButton( onPressed: () {}, icon: Icon(Icons.theater_comedy), )带图标的按钮
其实我们上述的这些按钮,大部分都可以说是一个可带图标的按钮,
因为ElevatedButton 、 TextButton、OutlinedButton 都有一个icon构造函授,通过它可以轻松的创建带图标的按钮,如下图
代码如下:
ElevatedButton.icon( onPressed: () {}, icon: Icon(Icons.send), label: Text("ElevatedButton"), ), TextButton.icon( onPressed: (){}, icon: Icon(Icons.safety_divider), label: Text("TextButton"), ), OutlinedButton.icon( onPressed: () {}, icon: Icon(Icons.abc), label: Text("OutlinedButton"), )下一节我将为大家介绍 图片及Icon 的使用
边栏推荐
- LVGL 8.2 Checkboxes as radio buttons
- [leetcode 239] sliding window
- LVGL 8.2 Checkboxes as radio buttons
- The life, working principle and application of electrochemical oxygen sensor
- 线代(高斯消元法、线性基)
- 微信表情符号被写入判决书,你发的每个 emoji 都可能成为呈堂证供
- LVGL 8.2 Image
- DQN笔记
- Jetpack Compose DropdownMenu跟随手指点击位置显示
- CP2112使用USB转IIC通信教学示例
猜你喜欢

China will force a unified charging interface. If Apple does not bow its head, iPhone will be kicked out of the Chinese market

File sharing server

科普达人丨漫画图解什么是eRDMA?

小程序中读取腾讯文档的表格数据

LVGL 8.2 Image

go语言defer

Mysql database foundation: views and variables

promise async和await的方法与使用

Wireguard simple configuration

IDEA 又出新神器,一套代码适应多端!
随机推荐
LVGL 8.2 Drop down in four directions
第一届中国数字藏品大会即将召开
sCrypt 中的 ECDSA 签名验证
The jetpack compose dropdownmenu is displayed following the finger click position
ESP32-C3入门教程 基础篇⑪——Non-Volatile Storage (NVS) 非易失性存储参数的读写
SQL必需掌握的100个重要知识点:分组数据
【STL源码剖析】迭代器
SQL必需掌握的100个重要知识点:汇总数据
Deep dive kotlin synergy (18): hot and cold data flow
SQL必需掌握的100个重要知识点:使用子查询
When does the database need to use the index [Hangzhou multi surveyors] [Hangzhou multi surveyors _ Wang Sir]
Unity Shader - 踩坑 - BRP 管线中的 depth texture 的精度问题(暂无解决方案,推荐换 URP)
LVGL 8.2 Image
Classic interview question: responsible modules, how do you design test cases for these function points? [Hangzhou multi surveyors] [Hangzhou multi surveyors \wang Sir]
Go语言学习之Switch语句的使用
Jetpack Compose DropdownMenu跟随手指点击位置显示
我们公司使用 7 年的这套通用解决方案,打通了几十个系统,稳的一批!
SQL必需掌握的100个重要知识点:插入数据
Kotlin 协程调度切换线程是时候解开谜团了
电商两位大佬花边新闻刷屏,代表电商回归正常,将有利于实体经济