hide method

Future<void> hide({
  1. bool animated = true,
})

Hides the tooltip.

Once hidden, the tooltip will be removed from the widget tree the next time the widget tree rebuilds, and stateful widgets in the tooltip may lose their states as a result.

This method should typically not be called while the widget tree is being rebuilt.

Testing

To avoid timeouts in widget tests, always wrap the returned Future in unawaited.

testWidgets('shows', (tester) async {
  await tester.pumpWidget(...);

  unawaited(controller.show());
  await tester.pumpAndSettle();
});

Implementation

Future<void> hide({bool animated = true}) async {
  if (!_animation.isForwardOrCompleted) {
    return;
  }

  if (animated) {
    await _animation.reverse();
  } else {
    _animation.value = 0;
  }
  _overlay.hide();
  notifyListeners();
}