RaisedButton属性解析

RaisedButton属性列表
RaisedButton属性列表

我们挨个说明属性的作用及用法:

onPressed   用户点击此按钮时的回调函数。
RaisedButton(
  onPressed: () {
    //点击事件处理
  }
)
onLongPress   和上面一样的,用户长按此按钮时的回调函数。
RaisedButton(
  onLongPress: () {
    //长按事件处理
  }
)
onHighlightChanged   水波纹高亮变化回调
RaisedButton(
  onHighlightChanged: (bool) {
    debugPrint(bool.toString());//有水波纹时返回true,水波纹消失(放开按钮)返回false
  }
)
textTheme   按钮的样式(文字颜色、按钮的最小大小,内边距以及shape)
RaisedButton(
  textTheme: ButtonTextTheme.accent,//改变了文字颜色和点击背景色
)
textColor   文本颜色
RaisedButton(
  textColor: Color(0xFFFFFF),
)
disabledTextColor   禁用状态下的文本颜色
color   背景颜色
disabledColor   禁用状态下的背景颜色
focusColor   获取焦点之后的背景色吧,没有测试出来
hoverColor   鼠标悬停在按钮上的时候的背景色
highlightColor   水波纹颜色
splashColor   扩散水波纹的颜色
colorBrightness   背景亮度(dark/light)
elevation   阴影深度
focusElevation   聚焦时阴影深度
hoverElevation   鼠标悬停时阴影深度
highlightElevation   水波纹变化时阴影深度
disabledElevation   禁用时阴影深度
padding   内边距
shape   形状,需要使用ShapeBorder的子类,如
shape: RoundedRectangleBorder (
  borderRadius: BorderRadius.all(Radius.circular(50))
)

设置圆角

clipBehavior   裁剪(none/hardEdge/antiAlias/antiAliasWithSaveLayer),默认是none,不裁剪
focusNode   监听及控制焦点,详情看https://developer.aliyun.com/article/763095
autofocus   是否自动获取焦点,默认false
materialTapTargetSize   是配置组件点击区域大小的属性,有2个值,分别为:
  • padded:最小点击区域为48*48。
  • shrinkWrap:子组件的实际大小。
animationDuration   时长,具体是什么的时长,没试出来
child   子控件,一般用来显示文字,如下
RaisedButton(
  child: Text('继续拍照'),
)

可以给背景加个渐变色效果

RaisedButton(
  child: Container(
    decoration: const BoxDecoration(
      gradient: LinearGradient(
        colors: <Color>[
          Color(0xFF0D47A1),
          Color(0xFF1976D2),
          Color(0xFF42A5F5),
        ],
      ),
    ),
    padding: const EdgeInsets.all(10.0),
    child: const Text('Gradient Button',
    style: TextStyle(fontSize: 20)),
  ),
)

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值