Icon" isn't a subtype of "IconData"

I am passing an IconData object as a parameter to a Widget, but I am getting the following error: Type 'Icon' is not a subtype of type 'IconData' in type case. I have attempted to find solutions to this issue on StackOverflow, but have not been able to resolve the error.

The following code is an example of what I am trying to do:

// gradientCardSample("کلی", 12, context, IconData(Icon(Icons.ac_unit) as int)),
gradientCardSample("عشق", 12, context, const Icon(Icons.book, size: 20, color: Colors.blue,) as IconData),

The issue is that you are trying to pass an Icon object as an IconData parameter.

To fix the issue, you should pass the IconData directly without casting it to an Icon object.

Here’s the corrected code:

gradientCardSample("کلی", 12, context, Icons.ac_unit),
gradientCardSample("عشق", 12, context, Icons.book),

Make sure to remove the unnecessary casting and use the IconData directly.