Iteo/theme_tailor

Supporting non-list types

rotorgames opened this issue · 3 comments

Is there any know limitations why Tailor doesn't support non-list types for @Tailor approach?

I guess using non-list types can reduce boilerplate in case when we have the same value for all themes.

For example:

From

@Tailor()
class _$AppTheme {
  static const padding = EdgeInsets.only(right: 4);
}

To

class AppTheme extends ThemeExtension<AppTheme> {
  const AppTheme({
    required this.padding,
  });

  final EdgeInsets padding;

  static final AppTheme light = AppTheme(
    padding: _$AppTheme.padding,
  );

  static final AppTheme dark = AppTheme(
    padding: _$AppTheme.padding,
  );

  static final themes = [
    light,
    dark,
  ];
  
  ...
  
}

I believe it looks much better then using a list and copying the same values twice.

Thoughts?

@rotorgames Have you found a solution for this problem? I'm going to solve it with a fork of the theme_tailor.

@ChaserVasya I tried solving it, unfortunately it looks a bit more challenging I expected. So I started using a class with static fields for non-theme values instead.

Rongix commented

Hello,
Apologies for the delayed response. It all comes down how the generator (@Tailor) parses the source code based on AST tree. Currently we don't plan on expanding the generator that works based on the static declarations and generally I'd recommend using ThemeTailorMixin
More info here: https://pub.dev/packages/theme_tailor#tailormixin