我想对Container小部件(包含一些其他小部件)执行非常简单的2D旋转.此小部件将围绕中心的单个固定点旋转,不会变形.
我try 将transform
属性与Matrix4.rotationZ
一起使用,这在一定程度上是可行的-但是锚点在top-left角,而不是center.有没有简单的方法来指定那个锚点?
此外,有没有一种更简单的方法来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,
);