使用flutter 的deoration时报错, 提醒:deoration和 color: 背景颜色不能共存,两者同时只能有一个
decoration能够设置边框、背景色、背景图片、圆角等属性,很是实用。对于transform这个属性,通常有过其余平台开发经验的,都大体了解,这种变换,通常不是变换的实际位置,而是变换的绘制效果,也就是说它的点击以及尺寸、间距等都是按照未变换前的。code
demoorm
new Container( constraints: new BoxConstraints.expand( height:Theme.of(context).textTheme.display1.fontSize * 1.1 + 200.0, ), decoration: new BoxDecoration( border: new Border.all(width: 2.0, color: Colors.red), color: Colors.grey, borderRadius: new BorderRadius.all(new Radius.circular(20.0)), image: new DecorationImage( image: new NetworkImage('http://h.hiphotos.baidu.com/zhidao/wh%3D450%2C600/sign=0d023672312ac65c67506e77cec29e27/9f2f070828381f30dea167bbad014c086e06f06c.jpg'), centerSlice: new Rect.fromLTRB(270.0, 180.0, 1360.0, 730.0), ), ), padding: const EdgeInsets.all(8.0), alignment: Alignment.center, child: new Text('Hello World', style: Theme.of(context).textTheme.display1.copyWith(color: Colors.black)), transform: new Matrix4.rotationZ(0.3), )
tips图片
color:用来设置container背景色,若是foregroundDecoration设置的话,可能会遮盖color效果。 decoration:绘制在child后面的装饰,设置了decoration的话,就不能设置color属性,不然会报错,此时应该在decoration中进行颜色的设置。 foregroundDecoration:绘制在child前面的装饰。