How can I have clickable text in the AppBar in Flutter
Use TextButton
:
appBar: AppBar(
actions: <Widget>[
TextButton(
onPressed: () {},
child: Text('Save'),
),
],
)
You can use FlatButton
within an AppBar
's actions
list:
appBar: AppBar(
title: Text("Test Screen"),
actions: <Widget>[
FlatButton(
textColor: Colors.white,
onPressed: () {},
child: Text("Save"),
shape: CircleBorder(side: BorderSide(color: Colors.transparent)),
),
],
),
onPressed
must be defined or the button will appear disabled.
Also note that by default the shape of the button will create a filled rectangle for the InkWell effect. By setting the shape
property to CircleBorder
, we get a nicer effect for the pressed state.
E.g.
Not pressed:
Pressed: