Repository navigation
InlineText's GestureDetector is always full-width #131435
Copy link
Copy link
Closed
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work lista: text inputEntering text in a text field or keyboard related problemsEntering text in a text field or keyboard related problemsteam-designOwned by Design Languages teamOwned by Design Languages teamtriaged-designTriaged by Design Languages teamTriaged by Design Languages team
Description
Is there an existing issue for this?
- I have searched the existing issues
- I have read the guide to filing a bug
Steps to reproduce
- Create a TextSpan with a
recognizerproperty, or use the app below. - Run the app on a platform with a mouse.
- Hover over the space to the right of the TextSpan.
Expected results
Only "example.com" is tappable, as in a typical link on the web, for example. Here I've highlighted the area I expect to be tappable in blue (with an image editor, not with Flutter).
Actual results
The entire width, highlighted in blue, is tappable.
Related:
#27293
#13211
#125927
Code sample
Example code
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: 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 StatelessWidget {
const MyHomePage({Key? key, required this.title}) : super(key: key);
final String title;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
RichText(
text: TextSpan(
style: const TextStyle(
color: Colors.black,
),
text: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. ',
children: [
TextSpan(
text: 'example.com',
style: const TextStyle(
color: Colors.blue,
),
recognizer: TapGestureRecognizer()..onTap = () {},
),
],
),
),
],
),
),
);
}
}Screenshots or Video
Screenshots / Video demonstration
Logs
No response
Flutter Doctor output
Doctor output
Doctor summary (to see all details, run flutter doctor -v):
[!] Flutter (Channel master, 3.13.0-10.0.pre.49, on Debian GNU/Linux rodete 6.3.7-1rodete2-amd64, locale en_US.UTF-8)
! Upstream repository [email protected]:justinmc/flutter.git is not a standard remote.
Set environment variable "FLUTTER_GIT_URL" to [email protected]:justinmc/flutter.git to dismiss this error.
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
[✓] Chrome - develop for the web
[✓] Linux toolchain - develop for Linux desktop
[✓] Android Studio (version 2021.3)
[✓] Android Studio (version 2022.2)
[✓] Connected device (2 available)
[✓] Network resources
! Doctor found issues in 1 category.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work lista: text inputEntering text in a text field or keyboard related problemsEntering text in a text field or keyboard related problemsteam-designOwned by Design Languages teamOwned by Design Languages teamtriaged-designTriaged by Design Languages teamTriaged by Design Languages team


Activity
justinmc commentedon Jul 27, 2023
@LongCatIsLooong mentioned that there is a new Skia API that could affect this. Seems to be related to the hit test method of the TextSpan.
justinmc commentedon Aug 3, 2023
I should check if this issue is fixed after #131640 is merged.
dutsky commentedon Aug 9, 2023
I have same issue, and I'm sorry, do you know any workarounds, maybe? The only I had found is to add space character as children of
TextSpanwith recognizer. Something like that:justinmc commentedon Aug 9, 2023
I verified that #131640 does fix this problem! It was closed while waiting for a new Skia API, but the plan is to reopen it again after that.
justinmc commentedon Aug 9, 2023
@dutsky You could patch that PR into a local copy of Flutter if you really need a fix now. Otherwise I'm not aware of any workarounds.
letungcntt commentedon Aug 23, 2023
@justinmc Now, my project used flutter 3.7 how to fix it. I don't update because lib has crash with 3.10 or 3.13
justinmc commentedon Aug 24, 2023
@letungcntt How is this causing a crash? Are you able to post a minimal reproduction example?
I don't think there is a workaround until #131640 is merged, see #131640 (comment).
CC @LongCatIsLooong
Make `TextSpan` hit testing precise. (#139717)
Reverts "Make `TextSpan` hit testing precise." (#140468)
Make `TextSpan` hit testing precise. (flutter#139717)
Reverts "Make `TextSpan` hit testing precise." (flutter#140468)
Reland "Make `TextSpan` hit testing precise." (#140468) (#140621)
github-actions commentedon Jan 3, 2024
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.