i’m using "SubCategoryTiles" widget all over the app. initially i was using same Group Icon but now i want to use different-different category_Icon wherever i use this widget. So i want to know how to do it. See the code and also the image with error i’m getting.
class SubCategoryTiles extends StatelessWidget {
const SubCategoryTiles({
required this.titleText,
required this.onTapHandler,
required this.category_Icon,
});
final Widget titleText;
final VoidCallback onTapHandler;
final IconData category_Icon;
@override
Widget build(BuildContext context) {
return ListTile(
leading: const CircleAvatar(
backgroundColor: Colors.white,
child: category_Icon,
// Icon(
// Icons.group,
// color: Colors.deepOrange,
// ),
),
title: titleText,
trailing: const Icon(Icons.arrow_right),
onTap: onTapHandler,
);
}
}
2
Answers
The should be like this:
// This is how it should be added when you require it.
category_Icon: Icons.add_box,
Wrap your category_Icon in a Icon widget
IconData is not a widget, but an Icon is.