I am creating a widget for prouducttile and it has required field 'color' and here I want to apply shade like Colors.blue[40] but it does not work
and another question is what should be it's datatype if I pass Colors.blue[20] to my custom widget
how to solve
class ProductTile extends StatelessWidget {
final String name;
final double price;
final bool isfav;
final String imageurl;
final Color color;
const ProductTile({Key? key,required this.name,required this.isfav,required this.color,required this.imageurl,required this.price}) : super(key: key);
@override
Widget build(BuildContext context) {
return Container(
color: color[50],//showing an error
child: Center(child: Text(name),),
);
}
}
CodePudding user response:
Use to Material Color
final MaterialColor color;