浅识Flutter 基本组件Scaffold
Scaffold是Flutter开发中实现Material Design布局结构的“脚手架”,只要是在Material Design中定义过的单个界面显示的布局组件元素,都可以用Scaffold绘制.
1. body
body属性用于设定当前页面所显示的主要内容,它主要由多个Widget元素组成。
2. backgroundColor
backgroundColor属性用于设定当前页面内容的背景色,默认使用的是ThemeData.scaffoldBackgroundColor .
backgroundColor: Colors.yellowAccent,
class yangxdpage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
/*设置导航栏*/
appBar: AppBar(title:Text('养心殿')), /*设置导航栏*/
backgroundColor: Colors.yellowAccent,
body: Center(
child: GestureDetector(
onTap: () {
print("皇上起驾");
Navigator.pushNamed(context, "/hougong");//连接到hougong路由 路由名hougong
},
child: Text("起驾后宫"),
),
), //GestureDetector手势检测组件
)