showBy method
showBy基本都show菜单等,所以暂时不提供返回值
Implementation
@override
void showBy(Widget widget, ContextGetter contextGetter) {
final RenderBox assigner = contextGetter.context.findRenderObject()! as RenderBox;
final RenderBox overlay = context.findRenderObject()! as RenderBox;
var size = assigner.size;
var parentSize = overlay.size;
var leftTop = assigner.localToGlobal(Offset.zero, ancestor: overlay);
double? left;
double? top;
double? bottom;
double? right;
if (leftTop.dx + size.width / 2 > parentSize.width / 2) {
right = parentSize.width - (leftTop.dx + size.width);
} else {
left = leftTop.dx;
}
if (leftTop.dy + size.height / 2 > parentSize.height / 2) {
bottom = parentSize.height - leftTop.dy;
} else {
top = leftTop.dy + size.height;
}
var background = GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
removeWidget(widget);
},
child: const SizedBox.expand(),
);
showWidget(widget, background: background, top: top, left: left, bottom: bottom, right: right, level: 1);
// childMap[widget] = [widget, background];
}