[英]How can I implement OnPressed callback for Text widget, Flutter
I have a Text widget
on pressing which another Route
has to be shown.我有一个Text widget
,按下它必须显示另一条Route
。 But I could not see any onPressed() method for the Text widget
.但是我看不到Text widget
的任何 onPressed() 方法。 Please Help.请帮忙。
I have a Text widget
on pressing which another Route
has to be shown.我有一个Text widget
,必须按下该Text widget
才能显示另一条Route
。 But I could not see any onPressed() method for the Text widget
.但是我看不到Text widget
任何onPressed()方法。 Please Help.请帮忙。
I have a Text widget
on pressing which another Route
has to be shown.我有一个Text widget
,必须按下该Text widget
才能显示另一条Route
。 But I could not see any onPressed() method for the Text widget
.但是我看不到Text widget
任何onPressed()方法。 Please Help.请帮忙。
I have a Text widget
on pressing which another Route
has to be shown.我有一个Text widget
,必须按下该Text widget
才能显示另一条Route
。 But I could not see any onPressed() method for the Text widget
.但是我看不到Text widget
任何onPressed()方法。 Please Help.请帮忙。
I have a Text widget
on pressing which another Route
has to be shown.我有一个Text widget
,必须按下该Text widget
才能显示另一条Route
。 But I could not see any onPressed() method for the Text widget
.但是我看不到Text widget
任何onPressed()方法。 Please Help.请帮忙。
Wrap your text with container
and then again wrap your text with widget GestureDetector
and use onTap()
in the following way用container
包裹你的文本,然后再次用小部件GestureDetector
包裹你的文本,并按以下方式使用onTap()
onTap: () {
Navigator.of(context).pushReplacement(
MaterialPageRoute(builder: ((context) => *className()*)
);
},
There are many ways to create clickable text.有许多方法可以创建可点击的文本。
InkWell GestureDetector TextButton InkWell GestureDetector 文本按钮
Widget clickableText(Function() onShow) {
return Column(
children: [
InkWell(
onTap: () {
onShow();
},
child: Center(
child: Text(
"Text one",
style: TextStyle(fontSize: 40),
),
),
),
GestureDetector(
onTap: () {
onShow();
},
child: Center(
child: Text(
"Text one",
style: TextStyle(fontSize: 40),
),
),
),
TextButton(
onPressed: () {
onShow();
},
child: Text(
"clickable text",
style: TextStyle(fontSize: 40),
))
],
);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.