theme_extensions_builder_annotation
7.5.0, released 2 months ago by pro100.dev
Annotations for generating boilerplate code for Flutter ThemeExtension classes.
What it does
Provides annotations like @ThemeExtensions and @ThemeGen that work with the theme_extensions_builder package to automatically generate code for Flutter theme extensions. It handles things like lerping, copyWith, and context accessors.
AI-written summary of version 7.5.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You are using theme_extensions_builder to create custom Flutter theme extensions.
- You want to automatically generate boilerplate like copyWith and lerp for theme classes.
Skip it when
- You are not using theme_extensions_builder.
- You prefer writing your ThemeExtension boilerplate manually.
Strengths
- Reduces boilerplate code for custom Flutter theme extensions.
- Provides convenient annotations and field-level exclusions like @ignore.
Weaknesses
- Does nothing without the theme_extensions_builder package.
- Requires build_runner and code generation setup.
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- Yes (build_runner)
- Direct dependencies
- 1
Add theme_extensions_builder_annotation to dependencies, theme_extensions_builder and build_runner to dev dependencies, and run build_runner.
import 'package:flutter/material.dart';
import 'package:theme_extensions_builder_annotation/theme_extensions_builder_annotation.dart';
part 'my_theme.g.theme.dart';
@ThemeExtensions()
class MyTheme extends ThemeExtension<MyTheme> with _$MyTheme {
const MyTheme({
required this.primaryColor,
required this.spacing,
});
final Color primaryColor;
final double spacing;
}Alternatives
Packages that do the same job and could replace theme_extensions_builder_annotation.
- xdg_icons
XDG theme icons for Flutter.
62Compare - theme_extensions_gen
Generate Flutter ThemeExtensions from annotated templates with context accessors and no boilerplate.
62Compare
Works with
Packages commonly used together with theme_extensions_builder_annotation: ones it builds on, ones built on it, and its own family.
- stream_chat_flutterBuilt on theme_extensions_builder_annotationFull-featured Flutter UI SDK for Stream Chat, providing ready‑made chat widgets and theming.
- shadcn_uiBuilt on theme_extensions_builder_annotationFlutter port of the shadcn/ui design system with customizable components.
- theme_extensions_builderBuilt on theme_extensions_builder_annotationCode generator for Flutter ThemeExtension classes to minimize boilerplate code.
- shadBuilt on theme_extensions_builder_annotationA Flutter port of shadcn/ui with 40+ components and no Material dependency.