Caution
This package is experimental because the Dart macro system is currently under development.
DO NOT USE on production codes.
thema_demo.mp4
thema | Traditional |
---|---|
- Dart dev channel
- Flutter master channel
For more information, refer to the Macros documentation.
- Edit SDK constraints in
pubspec.yaml
:
environment:
sdk: ">=3.6.0-0 <4.0.0"
- Add the following dependencies to your
pubspec.yaml
:
dependencies:
thema: <version>
- Enable the experiment in
analysis_options.yaml
:
analyzer:
enable-experiment:
- macros
- enhanced-parts
Define a class with the @Thema
annotation:
@Thema()
class ColorThemeExt {
final Color primaryColor;
final Color secondaryColor;
final Color accentColor;
}
thema supports custom theme classes:
class GradientColor {
// You should implement the `lerp` static method.
static GradientColor? lerp(GradientColor? a, GradientColor? b, double t) {
// ...
}
}
@Thema()
class GradientColorThemeExt {
final GradientColor primaryGradient;
final GradientColor secondaryGradient;
final GradientColor accentGradient;
}
thema also supports nested ThemeExtension classes:
@Thema()
class AppThemeExt {
final ColorThemeExt color;
final GradientColorThemeExt gradientColor;
}
If you have any feature requests, please create an issue from this template.
If you find any bugs, please create an issue from this template.
Welcome your contributions!! Please read CONTRIBUTING docs before submitting your PR.