Iteo / theme_tailor

Code generator for Flutter's theme extension classes.
https://pub.dev/packages/theme_tailor
MIT License
79 stars 13 forks source link

Variables generated with type 'InvalidType' #84

Closed egonm12 closed 1 year ago

egonm12 commented 1 year ago

When I try to create a new theme with Theme Tailor my variables are generated with type 'InvalidType'.

Details

Project example: https://github.com/egonm12/theme_tailor_issue

filipwis commented 1 year ago

Hi, I have checked the issue by:

  1. Cloning your example project.
  2. Switching to Flutter version 3.10.6 and Dart version 3.0.6.
  3. Running dart run build_runner watch --delete-conflicting-outputs.

After following these steps, I noticed that every 'InvalidType' in the core_colors.tailor.dart file was changed to 'Color' type. It appears to be working correctly for me. Please kindly double-check the steps once again to ensure it's resolved.

Rongix commented 1 year ago

Hello, thank you for the provided code sample. I've conducted a review and found a few issues:

In app_colors.dart: The core and component variables should be declared as static final instead of const. These values are not constants. In component_colors.dart:

There are errors related to buttonBackground and buttonForeground. These variables are of type List, which makes them invalid as @themeExtension annotation targets since Color is not a ThemeExtension.

Additionally, it appears that CoreColors are not used as part of the theme in the provided sample. Unless there's a specific use case for them, they shouldn't be defined as ThemeExtension. (Initially, it seemed like these components had circular dependencies on themselves)

As a general recommendation, you might want to explore the ThemeTailorMixin generator, as it offers more capabilities with simpler syntax and reduces the chances of making these types of mistakes.

I'm going to close this for now, but please feel free to reach out if you have any further questions or require additional assistance.