马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
一、效果图
二、 实现方式
- 在必要体现筛选菜单的页面build中包裹一个Overlay组件
- 获取固定在顶部筛选头部Widget在屏幕上的位置和它的高度
- 在弹窗中通过获取到的高度举行内容体现地区定位
- 巧用AnimatedContainer组件实现下拉动画效果
- 末了在底部加上玄色蒙层
- _overlayEntry = OverlayEntry(builder: (_) {
- return Padding(
- padding: EdgeInsets.only(top: startY),
- child: Column(
- children: [
- ColoredBox(
- color: Colors.white,
- child: Column(
- children: [
- Container(
- height: 1,
- margin: const EdgeInsets.symmetric(horizontal: 16),
- color: const Color(0xfff6f7f9).withOpacity(0.8),
- ),
- ValueListenableBuilder<double>(
- valueListenable: _notifier,
- builder: (context, value, child) {
- return AnimatedContainer(
- height: value,
- curve: Curves.fastEaseInToSlowEaseOut,
- duration: const Duration(milliseconds: 300),
- child: child,
- );
- },
- child: widget.content,
- ),
- ],
- ),
- ),
- Expanded(
- child: GestureDetector(
- onTap: () => widget.controller.close(),
- behavior: HitTestBehavior.opaque,
- child: Container(
- color: Colors.black.withOpacity(0.7),
- ),
- ),
- ),
- ],
- ),
- );
- });
- Overlay.of(context).insert(_overlayEntry!);
复制代码 三、详细代码可查察此处的完备Demo
|