theme_code_gen_annotations 0.1.1
theme_code_gen_annotations: ^0.1.1 copied to clipboard
Annotations for theme_code_gen (used to mark classes for ThemeExtension generation).
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.1
dev_dependencies:
build_runner: ^2.4.0
theme_code_gen: ^0.1.1
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 = ...
}
@gradientAnnotation
class AppGradients {
static const Gradient surfaceLight = LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [Color(0xFFF5F5F5), Color(0xFFE0E0E0)],
);
static const Gradient surfaceDark = LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [Color(0xFF222222), Color(0xFF111111)],
);
}
Run:
dart run build_runner build
Generated classes:
AppColorsThemeColorsAppGradientsThemeGradientsAppTextThemeText