body:Center(
child: Container(
color: Colors.blue,
width: 400,
height: 200,
decoration:new BoxDecoration(
gradient: const LinearGradient(
colors: [
Colors.amber,
Colors.cyanAccent
])
)
),
)
如上面写法,在调试的时候会出现下面的报错。
Cannot provide both a color and a decoration
The color argument is just a shorthand for "decoration: new BoxDecoration(color: color)".
'package:flutter/src/widgets/container.dart':
Failed assertion: line 319 pos 15: 'color == null || decoration == null'
报错中告诉我们color属性和decoration 是不能同时存在的,一次我们需要把color移除即可。