Last active
January 15, 2020 16:08
-
-
Save ryanlid/50005399007ff190332a7b0e6b2028a7 to your computer and use it in GitHub Desktop.
AppBar 组件示例
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
void main() => runApp((MyApp())); | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
home: ScaffoldExample(), | |
title: "MaterialApp示例", | |
); | |
} | |
} | |
class ScaffoldExample extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
// 头部元素 | |
appBar: AppBar( | |
// 左侧图标 | |
leading: Icon(Icons.home), | |
// 标题 | |
title: Text('AppBar示例'), | |
// 操作按钮集 | |
actions: <Widget>[ | |
// 图标按钮 | |
IconButton( | |
icon: Icon( | |
Icons.search, | |
), | |
tooltip: "搜索", | |
onPressed: () {}, | |
), | |
IconButton( | |
icon: Icon(Icons.message), | |
tooltip: '消息', | |
onPressed: () {}, | |
) | |
], | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment