thema 0.1.0-dev02
thema: ^0.1.0-dev02 copied to clipboard
thema reduces the boilerplate code required to create ThemeExtension classes with macros.
Caution
This package is experimental because the Dart macro system is currently under development.
DO NOT USE on production codes.
thema | Traditional |
---|---|
Contents #
Requirements #
- Dart dev channel
- Flutter master channel
For more information, refer to the Macros documentation.
Setup #
- Edit SDK constraints in
pubspec.yaml
:
environment:
sdk: ">=3.6.0-0 <4.0.0"
copied to clipboard
- Add the following dependencies to your
pubspec.yaml
:
dependencies:
thema: <version>
copied to clipboard
- Enable the experiment in
analysis_options.yaml
:
analyzer:
enable-experiment:
- macros
- enhanced-parts
copied to clipboard
Usage #
Define a class with the @Thema
annotation:
@Thema()
class ColorThemeExt {
final Color primaryColor;
final Color secondaryColor;
final Color accentColor;
}
copied to clipboard
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;
}
copied to clipboard
thema also supports nested ThemeExtension classes:
@Thema()
class AppThemeExt {
final ColorThemeExt color;
final GradientColorThemeExt gradientColor;
}
copied to clipboard
Feature requests #
If you have any feature requests, please create an issue from this template.
Bug reports #
If you find any bugs, please create an issue from this template.
Contributing #
Welcome your contributions!! Please read CONTRIBUTING docs before submitting your PR.