1、Center介紹
Center将子控件放在其内部中心,裡面隻能放一個child,但是child裡面可以放Container

Center繼承勒Align,然後Align預設是center.
2、測試代碼
測試1、
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'open url',
home: Scaffold(
appBar: AppBar(
// Here we take the value from the MyHomePage object that was created by
// the App.build method, and use it to set our appbar title.
title: Text('hello flutter'),
),
body: Center(
child: Text("chenyu"),
),
),
);
}
}
測試2、
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'open url',
home: Scaffold(
appBar: AppBar(
// Here we take the value from the MyHomePage object that was created by
// the App.build method, and use it to set our appbar title.
title: Text('hello flutter'),
),
body: Center(
child: Container(
color: Colors.blue,
width: 200,
height: 200,
),
),
),
);
}
}