Repository: flutter
Issue: When called from a Button child inside Tooltip, `ensureTooltipVisible()` does not work with long press
Labels: c: new feature,framework,f: material design,f: gestures,has reproducible steps,P3,workaround available,team-design,triaged-design,found in release: 3.24,found in release: 3.27

### Steps to reproduce

1. Create a `Tooltip` widget with the following properties:
   - A `triggerMode` of `TooltipTriggerMode.tap`
   - A `child` that contains a `Button` whose `onPressed` calls `TooltipState.ensureTooltipVisible()`
2. Tap on the button

### Expected results

The tooltip should appear when the button is tapped, since `TooltipState.ensureTooltipVisible()` was called

Incidentally, other children of the tooltip aside from the button should also display the tooltip since `triggerMode` is `TooltipTriggerMode.tap`

### Actual results

The tooltip does not appear when the button is tapped. Or sometimes it does appear but this is very sporadic.

Based on some rudimentary debugging, it appears the `onTapCancel` gesture is triggered when the button is tapped as well. The tooltip is effectively dismissed immediately after `ensureTooltipVisible()` is called

Note that tapping on other children of the tooltip still works and the tooltip is displayed correctly.

Also, note that this issue appeared somewhat recently. We were previously on Flutter 3.13 and did not have this issue. When upgrading to flutter 3.24 this issue appeared. 
I think ideally there is some logic so the `onTapCancel` logic does not trigger if the tooltip is showing due to `ensureTooltipVisible()`
I did not test other tooltip trigger modes such as `TooltipTriggerMode.longPress`, but it could also have this issue.

In the meantime, I found that adding a little delay before calling `ensureTooltipVisible()` works as a workaround

### Code sample

<details open><summary>Code sample</summary>

```dart
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Tooltip Issue',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const HomePage(),
    );
  }
}

class HomePage extends StatefulWidget {
  const HomePage({super.key});

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  final tooltipKey = GlobalKey<TooltipState>();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Tooltip Issue')),
      body: Align(
        alignment: Alignment.topCenter,
        child: Tooltip(
          key: tooltipKey,
          textAlign: TextAlign.left,
          richMessage: const TextSpan(
            children: [
              TextSpan(
                text: 'Warning 1: ',
                style: TextStyle(fontWeight: FontWeight.bold),
              ),
              TextSpan(
                  text: 'Lorem ipsum dolor sit amet, \n'
                      'consectetur adipiscing elit.'),
              TextSpan(text: '\n\n'),
              TextSpan(
                text: 'Warning 2: ',
                style: TextStyle(fontWeight: FontWeight.bold),
              ),
              TextSpan(text: 'Duis lacus mauris,\nefficitur non blandit a'),
            ],
          ),
          triggerMode: TooltipTriggerMode.tap,
          child: Row(
            mainAxisSize: MainAxisSize.min,
            children: [
              const Text('Your device has 2 warnings.'),
              IconButton(
                onPressed: () =>
                    tooltipKey.currentState?.ensureTooltipVisible(),
                icon: const Icon(Icons.warning),
              ),
            ],
          ),
        ),
      ),
    );
  }
}

```

</details>


### Screenshots or Video

<details open>
<summary>Screenshots / Video demonstration</summary>


https://github.com/user-attachments/assets/504a8677-d6f7-4cfb-b272-6acc9ac5fb7e



</details>


### Logs

_No response_

### Flutter Doctor output

<details open><summary>Doctor output</summary>

```console
[✓] Flutter (Channel stable, 3.24.3, on macOS 15.0.1 24A348 darwin-arm64, locale en-US)
    • Flutter version 3.24.3 on channel stable at /Users/KO16A46/Development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 2663184aa7 (4 weeks ago), 2024-09-11 16:27:48 -0500
    • Engine revision 36335019a8
    • Dart version 3.5.3
    • DevTools version 2.37.3

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
    • Android SDK at /Users/KO16a46/Library/Android/sdk
    • Platform android-34, build-tools 33.0.1
    • ANDROID_HOME = /Users/KO16a46/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.0.1)
    • Xcode at /Applications/Xcode-15.0.1.app/Contents/Developer
    • Build 15A507
    • CocoaPods version 1.15.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314)

[✓] IntelliJ IDEA Community Edition (version 2022.3.1)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] VS Code (version 1.93.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.98.0

[✓] Connected device (6 available)
    • sdk gphone64 arm64 (mobile)     • emulator-5554                        • android-arm64  • Android 12 (API 32) (emulator)
    • Brian’s iPhone (mobile)         • 00008110-001824D90C33801E            • ios            • iOS 18.0.1 22A3370
    • iPhone 15 Pro Max (mobile)      • 7E5F4EB4-12C7-4F0E-A56F-250B5682FF40 • ios            •
      com.apple.CoreSimulator.SimRuntime.iOS-17-0 (simulator)
    • macOS (desktop)                 • macos                                • darwin-arm64   • macOS 15.0.1 24A348 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad                • darwin         • macOS 15.0.1 24A348 darwin-arm64
    • Chrome (web)                    • chrome                               • web-javascript • Google Chrome 129.0.6668.90

[✓] Network resources
    • All expected network resources are available.

• No issues found!
```

</details>