【发布时间】:2021-10-20 21:17:11
【问题描述】:
我正在设计一个视频通话屏幕,我必须在孔屏幕之间管理 selfViewContainer。
在这个屏幕上,我已经管理了大部分用于水平对齐的部分,但是对于 vertical,它在有凹槽的设备中无法正常工作。
我想在拖动时从顶部最小填充 50
这是可拖动的橙色容器的代码
Widget _selfView() {
return Positioned(
top: _selfViewTop,
left: _selfViewLeft,
child: Draggable(
feedback: _draggableView(),
childWhenDragging: Container(),
child: _draggableView(),
onDragEnd: (dragDetail) {
var screenWidth = AspectSize.getScreenWidth(context: context);
var screenHeight = AspectSize.getScreenHeight(context: context);
_selfViewLeft = dragDetail.offset.dx;
_selfViewTop = dragDetail.offset.dy;
if (_selfViewLeft < (screenWidth / 2)) {
_selfViewLeft = 16.0;
} else if (_selfViewLeft > (screenWidth / 2)) {
_selfViewLeft = (screenWidth) - (_selfViewWidth + 16);
}
if (_selfViewLeft < 1.0) {
_selfViewLeft = 16.0;
} else if ((_selfViewLeft + _selfViewWidth) > screenWidth) {
_selfViewLeft = (screenWidth) - (_selfViewWidth + 16);
}
if (_selfViewTop < 1.0) {
_selfViewTop = 50;
} else if ((_selfViewTop + _selfViewHeight) > screenHeight) {
_selfViewTop = (screenHeight) - (_selfViewWidth + 50);
}
setState(() {});
},
),
);
}
对于这个 UI,我使用 Stack 小部件来管理容器,橙色容器用于显示呼叫者屏幕,蓝色容器将显示另一个人的照片。
请给我一些解决方案。
谢谢。
【问题讨论】:
标签: android ios flutter draggable