Commit 399a649 1 parent 61b3b39 commit 399a649 Copy full SHA for 399a649
File tree 2 files changed +32
-1
lines changed
2 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -529,7 +529,7 @@ class TooltipState extends State<Tooltip> with SingleTickerProviderStateMixin {
529
529
/// Returns `false` when the tooltip shouldn't be shown or when the tooltip
530
530
/// was already visible.
531
531
bool ensureTooltipVisible () {
532
- if (! _visible) {
532
+ if (! _visible || ! mounted ) {
533
533
return false ;
534
534
}
535
535
_showTimer? .cancel ();
Original file line number Diff line number Diff line change @@ -1053,6 +1053,37 @@ void main() {
1053
1053
gesture = null ;
1054
1054
});
1055
1055
1056
+ testWidgets ('Calling ensureTooltipVisible on an unmounted TooltipState returns false' , (WidgetTester tester) async {
1057
+ // Regression test for https://github.com/flutter/flutter/issues/95851
1058
+ await tester.pumpWidget (
1059
+ const MaterialApp (
1060
+ home: Center (
1061
+ child: Tooltip (
1062
+ message: tooltipText,
1063
+ child: SizedBox (
1064
+ width: 100.0 ,
1065
+ height: 100.0 ,
1066
+ ),
1067
+ ),
1068
+ ),
1069
+ ),
1070
+ );
1071
+
1072
+ final TooltipState tooltipState = tester.state (find.byType (Tooltip ));
1073
+ expect (tooltipState.ensureTooltipVisible (), true );
1074
+
1075
+ // Remove the tooltip.
1076
+ await tester.pumpWidget (
1077
+ const MaterialApp (
1078
+ home: Center (
1079
+ child: SizedBox .shrink (),
1080
+ ),
1081
+ ),
1082
+ );
1083
+
1084
+ expect (tooltipState.ensureTooltipVisible (), false );
1085
+ });
1086
+
1056
1087
testWidgets ('Tooltip shows/hides when hovered' , (WidgetTester tester) async {
1057
1088
const Duration waitDuration = Duration .zero;
1058
1089
TestGesture ? gesture = await tester.createGesture (kind: PointerDeviceKind .mouse);
You can’t perform that action at this time.
0 commit comments