Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
d69ae363
Unverified
Commit
d69ae363
authored
Aug 19, 2020
by
Jimmy Robert
Committed by
GitHub
Aug 19, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix tooltip position. (#60479)
parent
357ed4e6
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
72 additions
and
2 deletions
+72
-2
tooltip.dart
packages/flutter/lib/src/material/tooltip.dart
+10
-2
tooltip_test.dart
packages/flutter/test/material/tooltip_test.dart
+62
-0
No files found.
packages/flutter/lib/src/material/tooltip.dart
View file @
d69ae363
...
...
@@ -284,8 +284,16 @@ class _TooltipState extends State<Tooltip> with SingleTickerProviderStateMixin {
}
void
_createNewEntry
()
{
final
OverlayState
overlayState
=
Overlay
.
of
(
context
,
debugRequiredFor:
widget
,
);
final
RenderBox
box
=
context
.
findRenderObject
()
as
RenderBox
;
final
Offset
target
=
box
.
localToGlobal
(
box
.
size
.
center
(
Offset
.
zero
));
final
Offset
target
=
box
.
localToGlobal
(
box
.
size
.
center
(
Offset
.
zero
),
ancestor:
overlayState
.
context
.
findRenderObject
(),
);
// We create this widget outside of the overlay entry's builder to prevent
// updated values from happening to leak into the overlay when the overlay
...
...
@@ -309,7 +317,7 @@ class _TooltipState extends State<Tooltip> with SingleTickerProviderStateMixin {
),
);
_entry
=
OverlayEntry
(
builder:
(
BuildContext
context
)
=>
overlay
);
Overlay
.
of
(
context
,
debugRequiredFor:
widget
)
.
insert
(
_entry
);
overlayState
.
insert
(
_entry
);
SemanticsService
.
tooltip
(
widget
.
message
);
}
...
...
packages/flutter/test/material/tooltip_test.dart
View file @
d69ae363
...
...
@@ -99,6 +99,68 @@ void main() {
expect
(
tipInGlobal
.
dy
,
20.0
);
});
testWidgets
(
'Does tooltip end up in the right place - center with padding outside overlay'
,
(
WidgetTester
tester
)
async
{
final
GlobalKey
key
=
GlobalKey
();
await
tester
.
pumpWidget
(
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
Padding
(
padding:
const
EdgeInsets
.
all
(
20
),
child:
Overlay
(
initialEntries:
<
OverlayEntry
>[
OverlayEntry
(
builder:
(
BuildContext
context
)
{
return
Stack
(
children:
<
Widget
>[
Positioned
(
left:
300.0
,
top:
0.0
,
child:
Tooltip
(
key:
key
,
message:
tooltipText
,
height:
20.0
,
padding:
const
EdgeInsets
.
all
(
5.0
),
verticalOffset:
20.0
,
preferBelow:
false
,
child:
const
SizedBox
(
width:
0.0
,
height:
0.0
,
),
),
),
],
);
},
),
],
),
),
),
);
(
key
.
currentState
as
dynamic
).
ensureTooltipVisible
();
// Before using "as dynamic" in your code, see note at the top of the file.
await
tester
.
pump
(
const
Duration
(
seconds:
2
));
// faded in, show timer started (and at 0.0)
/************************ 800x600 screen
* ________________ * }- 20.0 padding outside overlay
* | o | * y=0
* | | | * }- 20.0 vertical offset, of which 10.0 is in the screen edge margin
* | +----+ | * \- (5.0 padding in height)
* | | | | * |- 20 height
* | +----+ | * /- (5.0 padding in height)
* |________________| *
* * } - 20.0 padding outside overlay
************************/
final
RenderBox
tip
=
tester
.
renderObject
(
_findTooltipContainer
(
tooltipText
),
);
final
Offset
tipInGlobal
=
tip
.
localToGlobal
(
tip
.
size
.
topCenter
(
Offset
.
zero
));
// The exact position of the left side depends on the font the test framework
// happens to pick, so we don't test that.
expect
(
tipInGlobal
.
dx
,
320.0
);
expect
(
tipInGlobal
.
dy
,
40.0
);
});
testWidgets
(
'Does tooltip end up in the right place - top left'
,
(
WidgetTester
tester
)
async
{
final
GlobalKey
key
=
GlobalKey
();
await
tester
.
pumpWidget
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment