Flutter AppBar控件

  1. AppBar控件
// appBar组件
class AppBarDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    // return SizedBox(
    //   height: 200.0,
    //   child: AppBar(
    //     title: Text('微信'),
    //     actions: [
    //       IconButton(
    //         icon: Icon(Icons.share),
    //         onPressed: null,
    //       ),
    //       IconButton(
    //         icon: Icon(Icons.plus_one),
    //         onPressed: null,
    //       )
    //     ],
    //   ),
    // );
    return SizedBox(
      height: 100,
      child: AppBar(
        title: Text('标题'),
        leading: Icon(Icons.home), // 左侧图标
        backgroundColor: Colors.blue, // 背景色
        centerTitle: true,
        actions: [
          IconButton(
            icon: Icon(Icons.share),
            onPressed: null,
          ),
          // popupMenu
          PopupMenuButton<String>(
              itemBuilder: (BuildContext context) => <PopupMenuItem<String>>[
                    PopupMenuItem<String>(
                      value: 'friendContent',
                      child: Text('分享到朋友圈'),
                    ),
                    PopupMenuItem<String>(
                      value: 'friend',
                      child: Text('分享到好友'),
                    )
                  ])
        ],
      ),
    );
  }
}
  1. 效果图
    在这里插入图片描述
Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐