美文网首页
flutter控件之按钮

flutter控件之按钮

作者: 肉肉要次肉 | 来源:发表于2023-04-24 17:19 被阅读0次

Material 组件库中提供了多种按钮组件ElevatedButton、TextButton、OutlineButton、IconButton。

ElevatedButton:它默认带有阴影和蓝色背景

ElevatedButton(child:Text("normal"),onPressed:(){},);

TextButton:文本按钮,默认背景透明并不带阴影

TextButton(child:Text("normal"),onPressed:(){},)

OutlineButton:默认有一个边框,不带阴影且背景透明

OutlineButton(child:Text("normal"),onPressed:(){},)

IconButton:一个可点击的Icon,不包括文字,默认没有背景

IconButton(icon:Icon(Icons.thumb_up),onPressed:(){},)

Icons有内置图标库

参考:Flutter Icons 内置图标库【转】 - 简书

带图标和文字的按钮

ElevatedButton、TextButton、OutlineButton都有一个icon 构造函数,通过它可以轻松创建带图标的按钮

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,),

相关文章

网友评论

      本文标题:flutter控件之按钮

      本文链接:https://www.haomeiwen.com/subject/gppujdtx.html