Flutter之FloatingActionButton组件

/**
    const FloatingActionButton({
    Key key,
    this.child,//按钮显示的内容
    this.tooltip,//长按时显示的提示
    this.foregroundColor,//前景色,影响到文字颜色
    this.backgroundColor,//背景色
    this.heroTag = const _DefaultHeroTag(),//hero效果使用的tag,系统默认会给所有FAB使用同一个tag,方便做动画效果
    this.elevation = 6.0,//未点击时阴影值
    this.highlightElevation = 12.0,//点击下阴影值
    @required this.onPressed,
    this.mini = false,//FloatingActionButton有regular, mini, extended三种类型,默认为false即regular类型,true时按钮变小即mini类型,extended需要通过FloatingActionButton.extended()创建,可以定制显示内容
    this.shape = const CircleBorder(),//定义FAB的shape,设置shape时,默认为CircleBorder,RoundedRectangleBorder圆角矩形。
    this.clipBehavior = Clip.none,
    this.materialTapTargetSize,
    this.isExtended = false,//是否为”extended”类型
    })
 */
FloatingActionButton 构造函数方式创建
floatingActionButton: FloatingActionButton(
          onPressed: () => print("FloatingActionButton"),
          child: Text("button"),
          tooltip: "按这么长时间干嘛",
          foregroundColor: Colors.red,
//          backgroundColor: Colors.red,
//          mini: true,
//            shape: CircleBorder()
        ),

FloatingActionButton extended方式创建
floatingActionButton: FloatingActionButton.extended(
  icon: Icon(Icons.alarm), label: Text("文本"), onPressed: () {},
shape: RoundedRectangleBorder(
                borderRadius: BorderRadius.all(Radius.circular(5))),
),
设置FloatingActionButton位置
//centerDocked 底部中间
//endDocked 底部右侧
//centerFloat 中间偏上
//endFloat 底部偏上
//startTop 左侧顶部
//endTop 右侧顶部
home: Scaffold(
        appBar: AppBar(
          title: Text("FloatingActionButton"),
        ),
        body: Container(),
        floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
        floatingActionButton: FloatingActionButton(
          onPressed: () => print("FloatingActionButton"),
          child: Text("button"),
        ),
      ),

码云地址:https://gitee.com/xgljh/Flutter.git

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容