new InkWell(
onTap: () {
Navigator.pushNamed(context, "YourRoute");
},
child: new Padding(
padding: new EdgeInsets.all(10.0),
child: new Text("Tap Here"),
),
);
或
new FlatButton(
onPressed: () {
Navigator.pushNamed(context, "YourRoute");
},
child: new Text("Tap Here"),
)
GestureDetector(
onTap: () {
Navigator.pushNamed(context, "write your route");
},
onLongPress: (){
// open dialog OR navigate OR do what you want
}
child: new Text("Save"),
);
5条答案
按热度按时间inkz8wg91#
只需将你的标题 Package 在一个
GestureDetector
中来处理点击。然后调用Navigator
的pushNamed
来重定向到一个新的路径。64jmpszr2#
使用InkWell
这也会给你带来很好的涟漪React
或
ltskdhd13#
对于Flutter的所有部件,您可以使用这些部件实现onPressed
**1. InkWell():**使用此小部件,您可以在单击时添加涟漪效果
**2. GestureDetector():**使用此小部件,您可以实现onTap、onDoubleTap、onLongPress等操作
anauzrmj4#
你可以使用TextButton,因为它有一个透明的背景,看起来像一个文本小部件。
u7up0aaq5#
使用container将文本换行,然后再次使用小部件**“GestureDetector”将文本换行,并按以下方式使用onTap()**