【发布时间】:2017-05-26 23:11:14
【问题描述】:
我想执行一个非常简单的 Container 小部件(包含一些其他小部件)的 2D 旋转。这个小部件将围绕中心的一个固定点旋转,没有变形。
我尝试将transform 属性与Matrix4.rotationZ 一起使用,这有点工作 - 但锚点位于左上角角,而不是中心 .有没有一种简单的方法来指定该锚点?
此外,有没有更简单的方法来 2D 旋转这个不需要 Matrix4 的小部件?
var container = new Container (
child: new Stack (
children: [
new Image.asset ( // background photo
"assets/texture.jpg",
fit: ImageFit.cover,
),
new Center (
child: new Container (
child: new Text (
"Lorem ipsum",
style: new TextStyle(
color: Colors.white,
fontSize: 42.0,
fontWeight: FontWeight.w900
)
),
decoration: new BoxDecoration (
backgroundColor: Colors.black,
),
padding: new EdgeInsets.fromLTRB(16.0, 16.0, 16.0, 16.0),
transform: new Matrix4.rotationZ(0.174533), // rotate -10 deg
),
),
],
),
width: 400.0,
height: 200.0,
);
【问题讨论】: