Skip to content

Commit 288fab8

Browse files
committed
Migrate the material Tooltip to use windowing
1 parent 152be74 commit 288fab8

File tree

1 file changed

+37
-2
lines changed

1 file changed

+37
-2
lines changed

packages/flutter/lib/src/material/tooltip.dart

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,41 @@ class Tooltip extends StatefulWidget {
472472
}
473473
}
474474

475+
class _TooltipStateController {
476+
_TooltipStateController({required this.useWindowing}) {
477+
if (this.useWindowing) {
478+
} else {
479+
overlayPortalController = OverlayPortalController();
480+
}
481+
}
482+
483+
final bool useWindowing;
484+
late final OverlayPortalController? overlayPortalController;
485+
late final TooltipWindowController? tooltipWindowController;
486+
487+
bool get isShowing {
488+
if (useWindowing) {
489+
return false;
490+
} else {
491+
return overlayPortalController!.isShowing;
492+
}
493+
}
494+
495+
void show() {
496+
if (useWindowing) {
497+
} else {
498+
overlayPortalController!.show();
499+
}
500+
}
501+
502+
void hide() {
503+
if (useWindowing) {
504+
} else {
505+
overlayPortalController!.hide();
506+
}
507+
}
508+
}
509+
475510
/// Contains the state for a [Tooltip].
476511
///
477512
/// This class can be used to programmatically show the Tooltip, see the
@@ -490,7 +525,7 @@ class TooltipState extends State<Tooltip> with SingleTickerProviderStateMixin {
490525
static const bool _defaultEnableFeedback = true;
491526
static const TextAlign _defaultTextAlign = TextAlign.start;
492527

493-
final OverlayPortalController _overlayController = OverlayPortalController();
528+
final _TooltipStateController _overlayController = _TooltipStateController(useWindowing: false);
494529

495530
// From InheritedWidgets
496531
late bool _visible;
@@ -948,7 +983,7 @@ class TooltipState extends State<Tooltip> with SingleTickerProviderStateMixin {
948983
);
949984
}
950985
return OverlayPortal(
951-
controller: _overlayController,
986+
controller: _overlayController.overlayPortalController!,
952987
overlayChildBuilder: _buildTooltipOverlay,
953988
child: result,
954989
);

0 commit comments

Comments
 (0)