Reputation: 11
class ReusableCard extends StatelessWidget {
ReusableCard({required this.colour, this.cardChild});
final Color colour;
Widget cardChild;
@override
Widget build(BuildContext context) {
return Container(
child: cardChild,
margin: EdgeInsets.all(15.0),
decoration: BoxDecoration(
color: Color(0xFF1D1E33),
borderRadius: BorderRadius.circular(10.0),
),
);
}
}
Upvotes: 1
Views: 37
Reputation: 23144
If you don't want it required you need to make it nullable by adding a ?
to the type of the variable. So change
Widget cardChild;
to
Widget? cardChild;
Upvotes: 1