theme_code_gen 0.0.7

Package that uses code generation to create custom colors, fonts, etc.

Package that uses code generation to create custom colors, fonts, etc.

Features

Using the familiar flutter pub run build_runner build command and anotations, you can generate your own code to create the appropriate ThemeExtension

Getting started

Add the following packages to your pubspec.yaml file:

  • build_runner
  • current package

Сreate a class with your custom colours or textual styles (all fields should be "static") and label the class with the appropriate annotation (for colours - @color_anotation, for text - @text_anotation).

Don't forget to add the following line

  • part '-your file name-.g.dart';

Run the following command

  • flutter pub run build_runner build

You will get the generated files, with the ThemeExtension ready. After generating the files, you must remove all dependencies (theme_code_get). Each color must have a realization "Dark" and "Light". Be sure to use each color at the end of the name "Light" or "Dark".

Usage

@text_anotation
class ConstantText {
  static TextStyle text1 = const TextStyle(fontSize: 33);
  static TextStyle text2 = const TextStyle(fontSize: 23);
}
@color_anotation
class ConstantColor {
  static const bgLight = Color(0xFF489D91);
  static const bgDark = Color(0xFF489D91);
}