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
399a649e
Unverified
Commit
399a649e
authored
Jun 22, 2022
by
Bruno Leroux
Committed by
GitHub
Jun 22, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix TooltipState null check error (#106330)
parent
61b3b399
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
1 deletion
+32
-1
tooltip.dart
packages/flutter/lib/src/material/tooltip.dart
+1
-1
tooltip_test.dart
packages/flutter/test/material/tooltip_test.dart
+31
-0
No files found.
packages/flutter/lib/src/material/tooltip.dart
View file @
399a649e
...
@@ -529,7 +529,7 @@ class TooltipState extends State<Tooltip> with SingleTickerProviderStateMixin {
...
@@ -529,7 +529,7 @@ class TooltipState extends State<Tooltip> with SingleTickerProviderStateMixin {
/// Returns `false` when the tooltip shouldn't be shown or when the tooltip
/// Returns `false` when the tooltip shouldn't be shown or when the tooltip
/// was already visible.
/// was already visible.
bool
ensureTooltipVisible
()
{
bool
ensureTooltipVisible
()
{
if
(!
_visible
)
{
if
(!
_visible
||
!
mounted
)
{
return
false
;
return
false
;
}
}
_showTimer
?.
cancel
();
_showTimer
?.
cancel
();
...
...
packages/flutter/test/material/tooltip_test.dart
View file @
399a649e
...
@@ -1053,6 +1053,37 @@ void main() {
...
@@ -1053,6 +1053,37 @@ void main() {
gesture
=
null
;
gesture
=
null
;
});
});
testWidgets
(
'Calling ensureTooltipVisible on an unmounted TooltipState returns false'
,
(
WidgetTester
tester
)
async
{
// Regression test for https://github.com/flutter/flutter/issues/95851
await
tester
.
pumpWidget
(
const
MaterialApp
(
home:
Center
(
child:
Tooltip
(
message:
tooltipText
,
child:
SizedBox
(
width:
100.0
,
height:
100.0
,
),
),
),
),
);
final
TooltipState
tooltipState
=
tester
.
state
(
find
.
byType
(
Tooltip
));
expect
(
tooltipState
.
ensureTooltipVisible
(),
true
);
// Remove the tooltip.
await
tester
.
pumpWidget
(
const
MaterialApp
(
home:
Center
(
child:
SizedBox
.
shrink
(),
),
),
);
expect
(
tooltipState
.
ensureTooltipVisible
(),
false
);
});
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