Skip to content

TapGestureRecognizer in TextSpan doesn't work inside Tooltip widget #113388

@ingmferrer

Description

@ingmferrer

Steps to Reproduce

  1. Execute flutter run on the code sample
  2. Click the "Tap me" text
  3. Click "url here" inside the tooltip.

Expected results:
See "url tapped" in the terminal.

Actual results:
No print output in the terminal.

Code sample
import 'package:flutter/gestures.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: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Tooltip(
          richMessage: TextSpan(
            text: 'Tap the ',
            style: const TextStyle(color: Colors.white),
            children: [
              TextSpan(
                text: 'url here',
                style: const TextStyle(color: Colors.yellow),
                recognizer: TapGestureRecognizer()
                  ..onTap = () {
                    print('url tapped');
                  },
              ),
            ],
          ),
          triggerMode: TooltipTriggerMode.tap,
          waitDuration: const Duration(minutes: 1),
          child: const Text('Tap me'),
        ),
      ),
    );
  }
}
Logs
NA
Analyzing ftest...                                                      

   info - Avoid `print` calls in production code - lib\main.dart:50:21 - avoid_print

1 issue found. (ran in 2.7s)
[√] Flutter (Channel stable, 3.3.4, on Microsoft Windows [Versi¢n 10.0.22621.674], locale es-CO)
    • Flutter version 3.3.4 on channel stable at C:\Users\ingfe\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision eb6d86ee27 (8 days ago), 2022-10-04 22:31:45 -0700
    • Engine revision c08d7d5efc
    • Dart version 2.18.2
    • DevTools version 2.15.0

[√] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at C:\Users\ingfe\AppData\Local\Android\sdk
    • Platform android-33, build-tools 31.0.0
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 11.0.12+7-b1504.28-7817840)
    • All Android licenses accepted.

[√] Android Studio (version 2021.2)
    • Android Studio at C:\Program Files\Android\Android Studio
    • 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 11.0.12+7-b1504.28-7817840)

[√] VS Code (version 1.72.1)
    • VS Code at C:\Users\ingfe\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.50.0

[√] Connected device (1 available)
    • sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64 • Android 12 (API 31) (emulator)

[√] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

Metadata

Metadata

Labels

P1High-priority issues at the top of the work listf: gesturesflutter/packages/flutter/gestures repository.f: material designflutter/packages/flutter/material repository.found in release: 3.3Found to occur in 3.3found in release: 3.4Found to occur in 3.4frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer version

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions