Flutter 导航栏上添加搜索按钮

代码:

Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('搜索条'),
actions: <Widget>[//导航条右方 类似rightBarItem
IconButton(
icon: Icon(Icons.search),
onPressed: (){
print('点击了搜索');
},
)
],
 
),
);
}
总结:
 

//导航栏上的搜索条

AppBar(

actions:<widget>{//类似于OC的rightBarItem

IconButton(

icon:Icon(Icons.xx)

Onpress(){

print(‘xxx’)//控制台输出

}

)

 

}

 

)

猜你喜欢

转载自www.cnblogs.com/pp-pping/p/12187162.html