I put a list of widget as action in Scaffold
appBar, but they didn't respond when I press them, I have a floatingButton
in the scene too and it works perfectly.
appBar: new AppBar(
title: new Text(
widget.title,
style: new TextStyle(
fontFamily: 'vazir'
),
),
centerTitle: true,
actions: <Widget>[
new IconButton(
icon: new Icon(Icons.search),
highlightColor: Colors.pink,
onPressed: _onSearchButtonPressed(),
),
],
),
void _onSearchButtonPressed() {
print("search button clicked");
}
even if I put IconButton in a Row
or Column
widget , not in appBar
, it doesn't work again.
Answer:
thanks to siva Kumar, I had a mistake in calling function , we should call it in this way:
onPressed: _onSearchButtonPressed, // without parenthesis.
or this way:
onPressed: (){
_onSearchButtonPressed();
},