Cannot provide both a color and a decoration To provide both, use “decoration: BoxDecoration(color: color)”. ‘package:flutter/src/widgets/container.dart‘: Failed assertion: line 285 pos 15: ‘color == null || decoration == null’

错误的原因是给Container 加圆角和阴影的时候出现

原因:deoration和 color:(背景颜色)不能共存,二者同时只能有一个。

原来:

Container(
            alignment: Alignment.center,
            color: Colors.red,
            decoration: BoxDecoration(
              color: Colors.white,
              borderRadius: BorderRadius.only(
                  bottomLeft: Radius.circular(6.0),
                  bottomRight: Radius.circular(6.0)),
              boxShadow: [
                BoxShadow(
                    color: Color.fromRGBO(155, 155, 155, 0.2),
                    offset: Offset(-1, 2),
                    blurRadius: 5,
                    spreadRadius: 5)
              ],
            ),

需要修改代码color: Colors.red, 去掉

修改以后:

 Container(
            alignment: Alignment.center,
            decoration: BoxDecoration(
              color: Colors.white,
              borderRadius: BorderRadius.only(
                  bottomLeft: Radius.circular(6.0),
                  bottomRight: Radius.circular(6.0)),
              boxShadow: [
                BoxShadow(
                    color: Color.fromRGBO(155, 155, 155, 0.2),
                    offset: Offset(-1, 2),
                    blurRadius: 5,
                    spreadRadius: 5)
              ],
            ),