How do I make some text tappable (respond to taps) in Flutter?

As seen on this answer, you can use an InkWell or a gesture detector.

For example

InkWell(
    child: Text("Hello"),
    onTap: () {print("value of your text");},
)

Or

var textValue = "Flutter"
InkWell(
    child: Text(textValue),
    onTap: () {print(textValue);},
)

EDIT : As Collin Jackson suggested, you can also use a FlatButton

FlatButton(
  onPressed: () {print("Hello world");},
  child: Text("Hello world"),
);

If you don’t need or require material (FlatButton, InkWell, etc), you can use GestureDetector:

GestureDetector(
  onTap: () { print("I was tapped!"); },
  child: Text("Hello world"),
)

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)