theme_tailor
4.0.2, released 2 weeks ago by iteo.com
Generates boilerplate for Flutter ThemeExtension classes using annotations.
What it does
Theme Tailor reads @TailorMixin annotations and creates mixins that implement copyWith, lerp, hashCode, and debugFillProperties for ThemeExtension subclasses. It also supports JSON serialization and custom type encoding.
AI-written summary of version 4.0.2, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to create many ThemeExtension classes and want to avoid manual boilerplate.
- You want compile‑time safety and IDE support for theme properties.
- You prefer a generator that works with build_runner.
Skip it when
- You only have a few simple theme extensions and don’t want a code generator.
- You cannot add build_runner or other dev dependencies to the project.
Strengths
- Eliminates repetitive ThemeExtension boilerplate
- Integrates with build_runner and supports custom encoders
- Handles JSON serialization and debug diagnostics automatically
Weaknesses
- Requires build_runner setup and dev dependencies
- Generated code may need manual tweaks for complex cases
Setup
- Kind
- Pure Dart
- Effort
- Medium
- Code generation
- Yes (build_runner)
- Direct dependencies
- 11
Add build_runner (dev), theme_tailor (dev), and theme_tailor_annotation (regular) dependencies, create part files, and run flutter pub run build_runner build.
import 'package:flutter/material.dart';
import 'package:theme_tailor_annotation/theme_tailor_annotation.dart';
part 'my_theme.tailor.dart';
@TailorMixin()
class MyTheme extends ThemeExtension<MyTheme> with _$MyThemeTailorMixin {
const MyTheme({required this.background});
final Color background;
}Alternatives
Packages that do the same job and could replace theme_tailor.
- theme_extensions_builder
Code generator for Flutter ThemeExtension classes to minimize boilerplate code.
77Compare - stacked_themes
Manage multiple themes, dark mode, and theme persistence in Flutter applications.
74Compare - theme_extensions_gen
Generate Flutter ThemeExtensions from annotated templates with context accessors and no boilerplate.
62Compare - xdg_icons
XDG theme icons for Flutter.
62Compare
Works with
Packages commonly used together with theme_tailor: ones it builds on, ones built on it, and its own family.
- analyzertheme_tailor depends on itPerforms static analysis of Dart code for tool integration and embedding.
- pub_semvertheme_tailor depends on itVersions and version constraints implementing pub's versioning policy.
- dart_styletheme_tailor depends on itProvides an API and CLI to format Dart source code automatically.
- json_annotationtheme_tailor depends on itProvides annotations for json_serializable to generate JSON (de)serialization code.
- buildtheme_tailor depends on itPackage for authoring build_runner compatible code generators.
- build_configtheme_tailor depends on itFormat definition and support for parsing build.yaml configuration.
- source_gentheme_tailor depends on itSource code generation builders and utilities for the Dart build system.
- source_helpertheme_tailor depends on itUtilities to help with Dart source code generation and string literal formatting.