theme_code_gen_annotations

Annotations for the theme_code_gen builder.

Use this package as a normal dependency (it is referenced from your source code), and use theme_code_gen as a dev_dependency to generate code.

Usage

pubspec.yaml:

dependencies:
  theme_code_gen_annotations: ^0.1.0

dev_dependencies:
  build_runner: ^2.4.0
  theme_code_gen: ^0.1.0

In your file:

import 'package:flutter/material.dart';
import 'package:theme_code_gen_annotations/theme_code_gen_annotations.dart';

part 'app_theme.g.dart';

@colorAnnotation
class AppColors {
  static const primaryLight = Color(0xFF00AAFF);
  static const primaryDark  = Color(0xFF0077AA);
}

@textAnnotation
class AppText {
  static const title = TextStyle(fontSize: 20, fontWeight: FontWeight.w600);
  // Or variants:
  // static const titleLight = ...
  // static const titleDark  = ...
}

Run:

flutter pub run build_runner build

Generated classes:

  • AppColorsThemeColors
  • AppTextThemeText