Flutter全局悬浮按钮,作为一个Android开发者

width: 56,

height: 56,

top: size.height - 72,

left: size.width - 72,

child: Material(

color: Colors.transparent,

child: GestureDetector(

onTap: () => print(‘ON TAP OVERLAY!’),

child: Container(

decoration: BoxDecoration(

shape: BoxShape.circle, color: Colors.redAccent),

),

),

),

);

}),

);

}

方法三

===

1.场景 现在需要做一个Test按钮,悬浮在所有页面之上,并且可以拖拽。

2.思路 1)悬浮按钮可以使用flutter提供的Overlay + OverlayEntry 组合实现

2)拖拽功能可以使用GestureDetector手势按钮或者Draggable实现(PS:我做了一版Draggable实现的,但是发现它会有原本的widget浮在原地,显然不是我要的效果)

3)点击的时候我是让它弹出一个底部弹框,这里你们可以自由发挥,本篇文章不做多余赘述

PubScaffold(

child: MaterialApp(

theme: CustomTheme.lightTheme,

darkTheme: CustomTheme.darkTheme,

themeMode: currentTheme.currentTheme,

home: Scaffold(

body: Stack(

children: [

_pageList[_currentIndex],

// Positioned(

// left: _offset.dx,

// top: _offset.dy,

// child: GestureDetector(

// onPanUpdate: (d) =>

// setState(() => _offset += Offset(d.delta.dx, d.delta.dy)),

// child: FloatingActionButton(

// onPressed: () {},

// backgroundColor: Colors.orange,

// child: Icon(Icons.add),

// ),

// ),

// ),

],

),

bottomNavigationBar: CurvedNavigationBar(

// key: _bottomNavigationKey,

index: 0,

height: 60.0,

items: [

Icon(Icons.home, size: 30),

Icon(Icons.list, size: 30),

Icon(Icons.compare_arrows, size: 30),

// Icon(I

  • 3
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值