includeWidget method
判断控件的位置是否在当前控件里面
Implementation
bool includeWidget(GlobalKey otherGlobalKey) {
RenderBox otherRenderBox = otherGlobalKey.currentContext?.findRenderObject() as RenderBox;
final Offset otherOffset =
otherRenderBox.localToGlobal(Offset(otherRenderBox.size.height / 2, otherRenderBox.size.height / 2));
final RenderBox renderBox = currentContext?.findRenderObject() as RenderBox;
// final Offset? offset = renderBox?.localToGlobal(Offset.zero);
final size = renderBox.size;
final Offset offset = renderBox.localToGlobal(Offset.zero);
if (otherOffset.dx > offset.dx &&
otherOffset.dx < offset.dx + size.width &&
otherOffset.dy > offset.dy &&
otherOffset.dy < offset.dy + size.height) {
debugPrint('otherOffset ${otherOffset.dy}');
return true;
}
return false;
}