DEV Community

Cover image for How I Fixed “Card Theme Error” in Flutter
Rohit Kumar
Rohit Kumar

Posted on

How I Fixed “Card Theme Error” in Flutter

While working on my Flutter project, I faced an issue where the CardTheme
was showing errors in Android Studio. In this post, I’ll explain why this
happens and how to fix it step by step.

I was trying to customize the Card Theme in my Flutter app, but every line
inside Card Theme was showing an error.

Error Code

CardTheme(
  elevation: 2,
  shape: RoundedRectangleBorder(
    borderRadius: BorderRadius.circular(12),
  ),
)

Enter fullscreen mode Exit fullscreen mode

The issue happened because CardTheme parameters changed in the latest
Flutter version. Wrapping it correctly and using the updated API fixes
the problem.

cardTheme: const CardTheme(
  elevation: 2,
)

Enter fullscreen mode Exit fullscreen mode

After applying this fix, all errors were removed and the app worked perfectly.

If you are facing similar issues in Flutter, I hope this post helps you.
Feel free to comment if you have questions.

Top comments (0)