Skip to content
pubscout

theme_tailor

4.0.2, released 2 weeks ago by iteo.com

Generates boilerplate for Flutter ThemeExtension classes using annotations.

$ flutter pub add theme_tailor
Source repository

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.

Works with

Packages commonly used together with theme_tailor: ones it builds on, ones built on it, and its own family.