Skip to content

Commit ca32350

Browse files
fix: 🩹 separated code of tooltip position delegate (#516)
1 parent 1df746b commit ca32350

File tree

3 files changed

+719
-597
lines changed

3 files changed

+719
-597
lines changed

lib/src/enum.dart

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,19 @@ enum TooltipPosition {
6969

7070
bool get isHorizontal => isRight || isLeft;
7171
bool get isVertical => isTop || isBottom;
72+
73+
TooltipPosition get opposite {
74+
switch (this) {
75+
case TooltipPosition.left:
76+
return TooltipPosition.right;
77+
case TooltipPosition.right:
78+
return TooltipPosition.left;
79+
case TooltipPosition.top:
80+
return TooltipPosition.bottom;
81+
case TooltipPosition.bottom:
82+
return TooltipPosition.top;
83+
}
84+
}
7285
}
7386

7487
enum TooltipActionPosition {

lib/src/tooltip/render_object_manager.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ class RenderObjectManager {
1919

2020
static Map<TooltipLayoutSlot, RenderObjectManager> renderObjects = {};
2121

22+
/// Clears renderObjects map
23+
static void clear() => renderObjects.clear();
24+
2225
/// Performs dry layout to calculate the preferred size without actually laying out
2326
Size performDryLayout(BoxConstraints constraints) {
2427
renderConstraints = constraints;
@@ -29,13 +32,19 @@ class RenderObjectManager {
2932
/// Performs actual layout on the RenderBox
3033
void performLayout(BoxConstraints constraints, {bool parentUsesSize = true}) {
3134
customRenderBox.layout(constraints, parentUsesSize: parentUsesSize);
35+
dryLayoutSize = customRenderBox.size;
3236
}
3337

3438
/// Gets the current size of the RenderBox
3539
Size get size => dryLayoutSize ?? customRenderBox.size;
3640

3741
Offset get getOffset => Offset(xOffset ?? 0, yOffset ?? 0);
3842

43+
MultiChildLayoutParentData get layoutParentData {
44+
assert(customRenderBox.parentData is MultiChildLayoutParentData);
45+
return customRenderBox.parentData! as MultiChildLayoutParentData;
46+
}
47+
3948
/// Sets the position of the RenderBox
4049
void setOffset(double x, double y) {
4150
xOffset = x;

0 commit comments

Comments
 (0)