-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Closed
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listf: gesturesflutter/packages/flutter/gestures repository.flutter/packages/flutter/gestures repository.found in release: 3.0Found to occur in 3.0Found to occur in 3.0found in release: 3.1Found to occur in 3.1Found to occur in 3.1frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work on
Description
Steps to Reproduce
- Execute
flutter runon the code sample - Tap on the
Hello Worldrich-text widget, and the console will show Hello World - Tap on the floating action button. It will update the value of the
gestureRecognizerin existedHello Worldrich-text widget.
Expected results:
- Before changing the value of the
gestureRecognizerin existedHello Worldrich-text widget, the console will show Hello World. - After changing the value, the console will show Hello Flutter.
Actual results:
- The console always shows Hello World whether or not the value of the
gestureRecognizeris changed.
Code sample:
class _MyHomePageState extends State<MyHomePage> {
late TapGestureRecognizer _tapGestureRecognizer;
@override
void initState() {
super.initState();
_tapGestureRecognizer = TapGestureRecognizer()
..onTap = () {
print('Hello World');
};
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: RichText(
text: TextSpan(
text: 'Hello World',
style: const TextStyle(color: Colors.black),
recognizer: _tapGestureRecognizer,
),
),
),
floatingActionButton: FloatingActionButton(
onPressed: () {
_updateRichText();
},
),
);
}
void _updateRichText() {
setState(() {
print('set state');
_tapGestureRecognizer.dispose();
_tapGestureRecognizer = TapGestureRecognizer()
..onTap = () {
print('Hello Flutter');
};
});
}
}Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listf: gesturesflutter/packages/flutter/gestures repository.flutter/packages/flutter/gestures repository.found in release: 3.0Found to occur in 3.0Found to occur in 3.0found in release: 3.1Found to occur in 3.1Found to occur in 3.1frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work on