flutter控件之按钮

2023-04-24  本文已影响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,),

上一篇 下一篇

猜你喜欢

热点阅读