根据Ian的建议,我尝试了以下方法。至少在我有限的测试中,它似乎有效。
容器嵌套在Transform小部件中。使用 alignment
可以相对地(即在中心,左上角等)调整变换原点。
var container = new Container ( child: new Stack ( children: [ new Image.asset ( // background photo "assets/texture.jpg", fit: ImageFit.cover, ), new Center ( child: new Transform ( 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), ), alignment: FractionalOffset.center, // set transform origin transform: new Matrix4.rotationZ(0.174533), // rotate -10 deg ), ), ], ), width: 400.0, height: 200.0, );