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