Flutter AppBar控件
- 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('分享到好友'),
)
])
],
),
);
}
}
- 效果图