繁体   English   中英

如何在我的应用栏上添加抽屉和搜索图标

[英]How to add a drawer and a search icon on my app bar in flutter

我是扑扑和探索它的新手。 我已经有一个应用程序栏,但我似乎无法弄清楚如何在其上正确显示抽屉图标和搜索图标。 我希望它看起来像下图的 gmail 应用程序栏。 我正在开发公司帮助台移动应用程序。 谢谢。

gmail 应用栏

按照flutter docs 中的说明进行操作

new AppBar( 
    title: new Text('My Fancy Dress'), 
    actions: <Widget>[ 
        new IconButton( icon: new Icon(Icons.playlist_play), tooltip: 'Air it', onPressed: _airDress, ),],
    leading: <Widget>[
        new IconButton( icon: new Icon(Icons.playlist_play), tooltip: 'Air it', onPressed: _airDress, ),
], )

领导下的小部件是抽屉,动作下的小部件是搜索图标按钮。

你可以试试这个代码....

      appBar: AppBar(
        leading: Builder(
            builder: (BuildContext context){
              return IconButton(
                icon: Icon(Icons.menu),
                onPressed: () {

                },
              );
            }),
        title: Text("Flutter App"),
        actions: <Widget>[
          IconButton(
            icon: Icon(Icons.search),
            onPressed: () {
            },
          ),
          IconButton(
            icon: Icon(Icons.search),
            onPressed: () {
            },
          )
        ],
      ),

这是最简单的

appBar: AppBar(
    actions: <Widget>[
      IconButton(
        icon: Icon(Icons.search),
        onPressed: () {},
      ),
      IconButton(
        icon: Icon(Icons.person),
        onPressed: () {
        },
      )
    ],
    centerTitle: true,
    backgroundColor: Colors.red,
    title: Text(
      "Your title",
      style: TextStyle(
        color: Colors.white,
        fontSize: 30,
        fontWeight: FontWeight.bold,
        fontStyle: FontStyle.italic,
      ),
    ),
  ),

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM