Expanded(
//flex: 2,
child: Row(
children: <Widget>[
Expanded(child: Reuseable(colour: Color(0xBAD681))),
Expanded(
child: Reuseable(colour: Color(0xBAD681)),
)
],
)),
class Reuseable extends StatelessWidget {
Reuseable({@required this.colour, this.cardChild});
final Color colour;
final Widget cardChild;
@override
Widget build(BuildContext context) {
return Container(
child: cardChild,
margin: EdgeInsets.all(15.0),
decoration: BoxDecoration(
border: Border.all(
color: Colors.grey,
),
color: colour,
borderRadius: BorderRadius.circular(10.0)),.
);
}
}
这是我用来创建自定义类的代码的一部分,由于某种原因我无法对其进行着色!如果没有边界,那么可重用类将是不可见的,为什么以及如何解决它的任何想法?
截屏:
<< img src =“ https://image.soinside.com/eyJ1cmwiOiAiaHR0cHM6Ly9pLnN0YWNrLmltZ3VyLmNvbS92NkczcC5wbmcifQ==” alt =“ https://i.ibb.co/pyMnVgJ/Screenshot>1592356692.png
Expanded(// flex:2,child:Row(children:
"decoration: new BoxDecoration(color: color)"
的简写。 从color
中删除Container
参数,并将其留在BoxDecoration:
中