AppBar布局及相关属性
AppBar属于基础组件,结构如下 以下示例显示一个带有两个简单操作的AppBar。第一个动作打开SnackBar,第二个动作导航到新页面。 import 'package:flutter/material.dart'; class LoginPage extends StatefulWidget { @override _LoginPageState createState() => _LoginPageState(); } class _LoginPageState extends State<LoginPage> { @override Widget build(BuildContext context) { final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>(); final SnackBar snackBar = const SnackBar(content: Text('Showing Snackbar')); return Scaffold( key: scaffoldKey, appBar: AppBar( title: const Text('AppBar Demo'), actions: <Widget>[ IconButton( icon: const Icon(Icons