我有一个模态底页。但我必须流利地拖动它。我知道我应该onVerticalDragUpdate
在 GestureDetector 中使用或其他东西,但我不知道怎么做?我用过onLongPressMoveUpdate
,就是不能流畅拖拽的原因。我应该触摸底部的纸张 2 秒钟,然后可以拖动它。我想为卡设置最小高度和最大高度。并且可以拖动它。任何人都可以帮助我改进它:
double position;
showModalBottomSheet(
context: context,
isScrollControlled: true,
isDismissible: true,
enableDrag: true,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(
top: Radius.circular(20),
),
),
clipBehavior: Clip.antiAliasWithSaveLayer,
builder: (context) {
return StreamBuilder(
stream: controller.stream,
builder: (context, snapshot) => GestureDetector(
onLongPressMoveUpdate: (details) {
position =
MediaQuery.of(context).size.height -
details.globalPosition.dy;
position.isNegative
? Navigator.pop(context)
: setState(() {
controller.add(position);
});
},
behavior: HitTestBehavior.translucent,
child: Container(
height: snapshot.hasData
? snapshot.data as double
: pageWidth * .55,
// width: double.infinity,
child: PlayerCardDialog(
epdId: episodes[index]['Ep_ID'],
)),
),
);
});