Stack即層疊布局控件,能夠?qū)⒆涌丶盈B排列跨嘉。
Stack控件的每一個(gè)子控件都是定位或不定位,定位的子控件是被Positioned控件包裹的汪拥。Stack控件本身包含所有不定位的子控件细卧,其根據(jù)alignment定位(默認(rèn)為左上角)劫恒。然后根據(jù)定位的子控件的top肚医、right悦穿、bottom和left屬性將它們放置在Stack控件上仓手。
class _home extends StatefulWidget {
@override
State<StatefulWidget> createState() {
return _homeState();
}
}
class _homeState extends State<_home> {
@override
Widget build(BuildContext context) {
// TODO: implement build
return new Scaffold(
appBar: new AppBar(
title: Text("title"),
centerTitle: true,
),
body: new Center(
child: new Stack(
children: <Widget>[
Image.network(
"http://a.hiphotos.baidu.com/image/h%3D300/sign=ca66f12cffd3572c79e29adcba116352/3b87e950352ac65cd08fc0b6f6f2b21192138a69.jpg"),
new Positioned(
top: 20.0,
left: 10.0,
right: 0.0,
bottom: 30.0,
child: new Text("Positioned",style:TextStyle(fontSize:18.0,color: Colors.white),)),
],
),
));
}
}