//……省略無關代碼…… child: new Column( children: <Widget>[ new SizedBox(height: 20.0), new Stack( alignment: const FractionalOffset(0.9, 0.1),//方法一 children: <Widget>[ new Image( image: new AssetImage("assets/images/illustration_11.jpg"), width: 300.0, height: 200.0, fit: BoxFit.cover, ), new Opacity( opacity: 0.8, child: new Image( image: new AssetImage("assets/images/illustration_12.jpg"), width: 200.0, height: 150.0, fit: BoxFit.cover, ), ), new GestureDetector( onTap: () { Fluttertoast.showToast(msg: "分享一下咯"); }, child: new Icon(Icons.share, color: Colors.white), ), ], ), new SizedBox(height: 20.0), new Stack( children: <Widget>[ new Image( image: new AssetImage("assets/images/illustration_11.jpg"), width: 300.0, height: 200.0, fit: BoxFit.cover, ), new Positioned(//方法二 right: 15.0, top: 15.0, child: new Icon( Icons.share, color: Colors.white, ), ), ], ) ], ), //……省略無關代碼……
使用alignment配合FractionalOffset
:對於FractionalOffset的參數,我是這麼理解的:至關於比例,第一個表明橫向的權重,第二個表明豎向的權重,橫0.9表明在橫向十分之九的位置,豎0.1表明在豎向十分之一的位置code
使用定位組件Positioned
,其中的top、right、buttom、left,直接表明,距離該方向的距離blog