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
839bd631
Unverified
Commit
839bd631
authored
Feb 25, 2022
by
xubaolin
Committed by
GitHub
Feb 25, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not crash if dispatch the mouse events before the tooltip overlay detached (#97268)
parent
a288bd5e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
3 deletions
+63
-3
tooltip.dart
packages/flutter/lib/src/material/tooltip.dart
+7
-3
tooltip_test.dart
packages/flutter/test/material/tooltip_test.dart
+56
-0
No files found.
packages/flutter/lib/src/material/tooltip.dart
View file @
839bd631
...
@@ -522,13 +522,17 @@ class _TooltipState extends State<Tooltip> with SingleTickerProviderStateMixin {
...
@@ -522,13 +522,17 @@ class _TooltipState extends State<Tooltip> with SingleTickerProviderStateMixin {
static
final
Set
<
_TooltipState
>
_mouseIn
=
<
_TooltipState
>{};
static
final
Set
<
_TooltipState
>
_mouseIn
=
<
_TooltipState
>{};
void
_handleMouseEnter
()
{
void
_handleMouseEnter
()
{
if
(
mounted
)
{
_showTooltip
();
_showTooltip
();
}
}
}
void
_handleMouseExit
({
bool
immediately
=
false
})
{
void
_handleMouseExit
({
bool
immediately
=
false
})
{
if
(
mounted
)
{
// If the tip is currently covered, we can just remove it without waiting.
// If the tip is currently covered, we can just remove it without waiting.
_dismissTooltip
(
immediately:
_isConcealed
||
immediately
);
_dismissTooltip
(
immediately:
_isConcealed
||
immediately
);
}
}
}
void
_createNewEntry
()
{
void
_createNewEntry
()
{
final
OverlayState
overlayState
=
Overlay
.
of
(
final
OverlayState
overlayState
=
Overlay
.
of
(
...
...
packages/flutter/test/material/tooltip_test.dart
View file @
839bd631
...
@@ -863,6 +863,62 @@ void main() {
...
@@ -863,6 +863,62 @@ void main() {
await
gesture
.
up
();
await
gesture
.
up
();
});
});
testWidgets
(
'Dispatch the mouse events before tip overlay detached'
,
(
WidgetTester
tester
)
async
{
// Regression test for https://github.com/flutter/flutter/issues/96890
const
Duration
waitDuration
=
Duration
.
zero
;
TestGesture
?
gesture
=
await
tester
.
createGesture
(
kind:
PointerDeviceKind
.
mouse
);
addTearDown
(()
async
{
if
(
gesture
!=
null
)
return
gesture
.
removePointer
();
});
await
gesture
.
addPointer
();
await
gesture
.
moveTo
(
const
Offset
(
1.0
,
1.0
));
await
tester
.
pump
();
await
gesture
.
moveTo
(
Offset
.
zero
);
await
tester
.
pumpWidget
(
const
MaterialApp
(
home:
Center
(
child:
Tooltip
(
message:
tooltipText
,
waitDuration:
waitDuration
,
child:
SizedBox
(
width:
100.0
,
height:
100.0
,
),
),
),
),
);
// Trigger the tip overlay.
final
Finder
tooltip
=
find
.
byType
(
Tooltip
);
await
gesture
.
moveTo
(
tester
.
getCenter
(
tooltip
));
await
tester
.
pump
();
// Wait for it to appear.
await
tester
.
pump
(
waitDuration
);
// Remove the `Tooltip` widget.
await
tester
.
pumpWidget
(
const
MaterialApp
(
home:
Center
(
child:
SizedBox
.
shrink
(),
),
),
);
// The tooltip overlay still on the tree and it will removed in the next frame.
// Dispatch the mouse in and out events before the overlay detached.
await
gesture
.
moveTo
(
tester
.
getCenter
(
find
.
text
(
tooltipText
)));
await
gesture
.
moveTo
(
Offset
.
zero
);
await
tester
.
pumpAndSettle
();
// Go without crashes.
await
gesture
.
removePointer
();
gesture
=
null
;
});
testWidgets
(
'Tooltip shows/hides when hovered'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Tooltip shows/hides when hovered'
,
(
WidgetTester
tester
)
async
{
const
Duration
waitDuration
=
Duration
.
zero
;
const
Duration
waitDuration
=
Duration
.
zero
;
TestGesture
?
gesture
=
await
tester
.
createGesture
(
kind:
PointerDeviceKind
.
mouse
);
TestGesture
?
gesture
=
await
tester
.
createGesture
(
kind:
PointerDeviceKind
.
mouse
);
...
...
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