当前位置:网站首页>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
- Time complexity and space complexity
- 焕发青春的戴尔和苹果夹击,两大老牌PC企业极速衰败
- sCrypt 中的 ECDSA 签名验证
- 国产自研系统的用户突破4亿,打破美国企业的垄断,谷歌后悔不迭
- 科普达人丨漫画图解什么是eRDMA?
- 中国将强制统一充电接口,苹果如不低头,iPhone将被踢出中国市场
- CP2112使用USB转IIC通信教学示例
- LVGL 8.2 Image styling and offset
- Rejuvenated Dell and apple hit each other, and the two old PC enterprises declined rapidly
猜你喜欢
![[STL source code analysis] iterator](/img/e8/7c69cf6e96ecfa053494397a21eff0.jpg)
[STL source code analysis] iterator

Dickinson's soul chooses its companion

The two e-commerce bigwigs' lacy news screens represent the return of e-commerce to normal, which will be beneficial to the real economy

Unity Shader - 踩坑 - BRP 管线中的 depth texture 的精度问题(暂无解决方案,推荐换 URP)

sCrypt 中的 ECDSA 签名验证

时间复杂度与空间复杂度
![[STL source code analysis] container (to be supplemented)](/img/69/0c6e0e8ecb3ebc8c9b8503f5a8b4e5.jpg)
[STL source code analysis] container (to be supplemented)

LVGL 8.2 Image

ArrayList与顺序表

深潜Kotlin协程(十八):冷热数据流
随机推荐
Retest the cloud native database performance: polardb is still the strongest, while tdsql-c and gaussdb have little change
LeetCode Algorithm 86. Separate linked list
pytorch 筆記 torch.nn.BatchNorm1d
Dell et Apple, deux entreprises de PC établies, se sont effondrées rapidement
100 important knowledge points that SQL must master: updating and deleting data
LVGL 8.2 Simple Drop down list
Ant financial's written test question: what can be quantified in the requirements document? [Hangzhou multi tester] [Hangzhou multi tester \wang Sir]
小程序中读取腾讯文档的表格数据
Time complexity and space complexity
Dickinson's soul chooses its companion
List介绍
LVGL 8.2 Image
Unity Shader - 踩坑 - BRP 管线中的 depth texture 的精度问题(暂无解决方案,推荐换 URP)
【IC5000教程】-01-使用daqIDEA图形化debug调试C代码
SQL必需掌握的100个重要知识点:插入数据
Matplotlib notes: contour & Contour
Key library function based on Hal Library
Qt之实现QQ天气预报窗体翻转效果
File sharing server
线代(高斯消元法、线性基)