flutter 中出现这个错误的原因,是因为color 与 decoration 同时存在:
child: Container(
child: const Text('hello world',
style: TextStyle(fontSize: 40.0),
),
alignment: Alignment.topLeft,
width: 500.0,
height: 400.0,
color: Colors.deepPurple,
padding: const EdgeInsets.fromLTRB(10.0, 0.0, 0.0, 0.0),
margin: const EdgeInsets.all(30.0),
decoration: const BoxDecoration(
gradient: LinearGradient(
colors: [
Colors.lightBlue,
Colors.greenAccent,
Colors.purple])
),
)
去掉 color 问题解决。