Material 组件库中提供了多种按钮组件ElevatedButton、TextButton、OutlineButton、IconButton。
ElevatedButton:它默认带有阴影和蓝色背景
![](https://img.haomeiwen.com/i1514045/15ee7a249a2a3c27.png)
ElevatedButton(child:Text("normal"),onPressed:(){},);
TextButton:文本按钮,默认背景透明并不带阴影
![](https://img.haomeiwen.com/i1514045/b03c9d53d5c1f4f6.png)
TextButton(child:Text("normal"),onPressed:(){},)
OutlineButton:默认有一个边框,不带阴影且背景透明
![](https://img.haomeiwen.com/i1514045/2715eea626392689.png)
OutlineButton(child:Text("normal"),onPressed:(){},)
IconButton:一个可点击的Icon,不包括文字,默认没有背景
![](https://img.haomeiwen.com/i1514045/22a68728b73e1d4d.png)
IconButton(icon:Icon(Icons.thumb_up),onPressed:(){},)
Icons有内置图标库
参考:Flutter Icons 内置图标库【转】 - 简书
带图标和文字的按钮
ElevatedButton、TextButton、OutlineButton都有一个icon 构造函数,通过它可以轻松创建带图标的按钮
![](https://img.haomeiwen.com/i1514045/5a0b647d7bba613c.png)
![](https://img.haomeiwen.com/i1514045/a6616e8ac7efa2f7.png)
ElevatedButton.icon(icon:Icon(Icons.send),label:Text("发送"),onPressed:_onPressed,),
OutlineButton.icon(icon:Icon(Icons.add),label:Text("添加"),onPressed:_onPressed,),
TextButton.icon(icon:Icon(Icons.info),label:Text("详情"),onPressed:_onPressed,),
网友评论