android shape 按钮背景_flutter好用的轮子推荐十三-flutter可展开选项的浮动按钮

46beb2965cd4613a65880f783ac6b318.png

前言

Flutter是谷歌的移动UI框架,可以快速在iOS和Android上构建高质量的原生用户界面。

IT界著名的尼古拉斯·高尔包曾说:轮子是IT进步的阶梯!热门的框架千篇一律,好用轮子万里挑一!Flutter作为这两年开始崛起的跨平台开发框架,其第三方生态相比其他成熟框架还略有不足,但轮子的数量也已经很多了。本系列文章挑选日常app开发常用的轮子分享出来,给大家提高搬砖效率,同时也希望flutter的生态越来越完善,轮子越来越多。

本系列文章准备了超过50个轮子推荐,工作原因,尽量每1-2天出一篇文章。

tip:本系列文章合适已有部分flutter基础的开发者,入门请戳:flutter官网

正文

轮子

  • 轮子名称:flutter_speed_dial
  • 轮子概述:flutter可展开选项的浮动按钮.
  • 轮子作者:dario.ielardi@gmail.com
  • 推荐指数:★★★★
  • 常用指数:★★★
  • 效果预览:

ae6579d728d4d013efa69cfb9eaab758.gif

安装

dependencies:
  flutter_speed_dial: ^1.2.4
import 'package:flutter_speed_dial/flutter_speed_dial.dart';

使用方法

最简单的使用:

return Scaffold(
    body: Container(),
    floatingActionButton: SpeedDial(
        child: Icon(Icons.add),
        children:[
            SpeedDialChild(
                child: Icon(Icons.accessibility),
                backgroundColor: Colors.red,
                label: '第一个按钮',
                labelStyle: TextStyle(fontSize: 18.0),
                onTap: () => print('FIRST CHILD')
            ),
            SpeedDialChild(
                child: Icon(Icons.brush),
                backgroundColor: Colors.orange,
                label: '第二个按钮',
                labelStyle: TextStyle(fontSize: 18.0),
                onTap: () => print('SECOND CHILD'),
            ),
            SpeedDialChild(
                child: Icon(Icons.keyboard_voice),
                backgroundColor: Colors.green,
                label: '第三个按钮',
                labelStyle: TextStyle(fontSize: 18.0),
                onTap: () => print('THIRD CHILD'),
            ),
         ]
    ),
);

可以配置的所有选项:

floatingActionButton: SpeedDial(
    marginRight: 25,//右边距
    marginBottom: 50,//下边距
    animatedIcon: AnimatedIcons.menu_close,//带动画的按钮
    animatedIconTheme: IconThemeData(size: 22.0),
    visible: isShow,//是否显示按钮
    closeManually: false,//是否在点击子按钮后关闭展开项
    curve: Curves.bounceIn,//展开动画曲线
    overlayColor: Colors.black,//遮罩层颜色
    overlayOpacity: 0.5,//遮罩层透明度
    onOpen: () => print('OPENING DIAL'),//展开回调
    onClose: () => print('DIAL CLOSED'),//关闭回调
    tooltip: 'Speed Dial',//长按提示文字
    heroTag: 'speed-dial-hero-tag',//hero标记
    backgroundColor: Colors.blue,//按钮背景色
    foregroundColor: Colors.white,//按钮前景色/文字色
    elevation: 8.0,//阴影
    shape: CircleBorder(),//shape修饰
    children: [//子按钮
        SpeedDialChild(
            child: Icon(Icons.accessibility),
            backgroundColor: Colors.red,
            label: '第一个按钮',
            labelStyle: TextStyle(fontSize: 18.0),
            onTap: (){
                onButtonClick(1);
            }
        ),
        SpeedDialChild(
            child: Icon(Icons.brush),
            backgroundColor: Colors.orange,
            label: '第二个按钮',
            labelStyle: TextStyle(fontSize: 18.0),
            onTap: (){
                onButtonClick(2);
            },
        ),
        SpeedDialChild(
            child: Icon(Icons.keyboard_voice),
            backgroundColor: Colors.green,
            label: '第三个按钮',
            labelStyle: TextStyle(fontSize: 18.0),
            onTap: (){
                onButtonClick(3);
            },
        ),
    ],
),

结尾

  • 轮子仓库地址:https://pub.flutter-io.cn/packages/flutter_speed_dial
  • 系列演示demo源码:https://github.com/826327700/flutter_plugins_demo
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值