// CircleAvatar 頭像 alignment和Positioned 不可同時使 用 Positioned(相當(dāng)于絕對定位 主要應(yīng)用于多個控件疊加的時候)
class MyStackWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Center(
child: Column(
children: <Widget>[
Stack(
// alignment: const FractionalOffset(0.5, 1),
children: <Widget>[
new CircleAvatar(
backgroundImage: new NetworkImage(
'https://dss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=1671247724,3484152546&fm=26&gp=0.jpg'),
radius: 100.0,
),
Positioned(
top: 160,
left: 70,
child: Container(
decoration: new BoxDecoration(
color: Colors.pink,
),
padding: EdgeInsets.all(10.0),
child: Text('漂亮MM'),
),
),
Positioned(
top: 10,
left: 160,
child: Text(
'VIP',
style: TextStyle(
color: Colors.blue,
fontSize: 25,
),
),
),
],
),
],
));
}
}
代碼內(nèi)部有解釋