Skip to content
/ thema Public

thema reduces the boilerplate code required to create ThemeExtension classes with macros.

License

Notifications You must be signed in to change notification settings

ronnnnn/thema

Repository files navigation

thema

thema reduces the boilerplate code required to create ThemeExtension classes with macros.

check pub license

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
thema traditional

Contents

Requirements

  • Dart dev channel
  • Flutter master channel

For more information, refer to the Macros documentation.

Setup

  1. Edit SDK constraints in pubspec.yaml:
environment:
  sdk: ">=3.6.0-0 <4.0.0"
  1. Add the following dependencies to your pubspec.yaml:
dependencies:
  thema: <version>
  1. Enable the experiment in analysis_options.yaml:
analyzer:
  enable-experiment:
    - macros
    - enhanced-parts

Usage

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;
}

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.

About

thema reduces the boilerplate code required to create ThemeExtension classes with macros.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published