Skip to content

mix-v2.0.1

Choose a tag to compare

@tilucasoli tilucasoli released this 30 Mar 13:27
· 194 commits to main since this release
image

Mix 2.0.1: The Next Chapter in Flutter Styling

Mix 2.0 introduces a fluent, type-safe styling system for Flutter with first-class variants, built-in animation APIs, and token-based theming. This release modernizes the developer experience by separating style semantics from widget structure while keeping composition ergonomic.

tl;dr

  • New fluent Styler API (BoxStyler, TextStyler, IconStyler, FlexBoxStyler, ImageStyler)
  • Inline dynamic variants (onHovered, onPressed, onDark, breakpoints, platform, and more)
  • Three animation models: implicit, phase, and keyframe
  • Typed design tokens with MixScope
  • Expanded widget and modifier ecosystem

What's Changed

Fluent Styler API

Mix 2.0 replaces prefix-heavy utility declarations with chainable, strongly typed stylers that are easier to discover in IDE autocomplete and safer to refactor.

final card = BoxStyler()
    .color(Colors.white)
    .paddingAll(16)
    .borderRounded(12)
    .onHovered(.color(Colors.grey.shade50))
    .onDark(.color(Colors.grey.shade900));

Box(style: card, child: child);

Callable Stylers

Stylers can be invoked directly as widget factories:

final box = BoxStyler().color(Colors.blue).size(100, 100)

box(child: child); // returns a Box

New Animation APIs

Mix now supports three animation types directly in style definitions, from simple state transitions to full timeline control:

  • Implicit animations for simple state transitions
  • Phase animations for ordered multi-step sequences
  • Keyframe animations for timeline-driven parallel tracks

Implicit (state/variant-driven)

final style = BoxStyler()
    .color(Colors.blue)
    .size(100, 100)
    .animate(.easeInOut(300.ms))
    .onHovered(.color(Colors.deepPurple).size(120, 120));

Phase (event-triggered multi-step flow)

final controller = PhaseAnimationController();
final base = BoxStyler().color(Colors.blue).size(100, 100);

PhaseAnimationBuilder(
  controller: controller,
  phases: [
    PhaseConfig(base.size(80, 80), duration: 150.ms, curve: .easeIn),
    PhaseConfig(base.size(120, 120), duration: 250.ms, curve: .bounceOut),
    PhaseConfig(base, duration: 180.ms, curve: .easeOut),
  ],
  builder: (context, phaseStyle) => Box(style: phaseStyle),
);

Keyframe (timeline + multiple tracks)

KeyframeAnimationBuilder(
  duration: 1200.ms,
  repeat: true,
  keyframes: {
    KeyframeTrack<double>(
      property: KeyframeProperty.iconSize,
      keyframes: [Keyframe(0.0, 40), Keyframe(0.5, 56), Keyframe(1.0, 40)],
    ),
    KeyframeTrack<Color>(
      property: KeyframeProperty.iconColor,
      keyframes: [Keyframe(0.0, Colors.red), Keyframe(1.0, Colors.red.shade800)],
    ),
  },
  builder: (context, keyframeStyle) => StyledIcon(style: baseIcon.merge(keyframeStyle)),
);

See the Animations Guide for full concepts, API details, and additional examples.

Breaking Changes

Mix 2.0 is a major API evolution. Migration from 1.x requires updates.

  • Prefix-based APIs like $box, $text, $on, and $with are replaced by fluent stylers
  • Widget names and style composition patterns may differ from 1.x conventions
  • Existing style declarations must be rewritten to the new chained method format

Migration reference:

Before / After Snapshot

// Before (1.x)
final style = Style(
  $box.color.blue(),
  $box.padding(16),
  $on.hover($box.color.red()),
);
// After (2.0)
final style = BoxStyler()
    .color(Colors.blue)
    .paddingAll(16)
    .onHovered(.color(Colors.red));

Ecosystem

  • mix: Core styling framework
  • mix_annotations: Annotation package for generation
  • mix_generator: build_runner generator for specs/stylers
  • mix_lint: Custom lint rules for Mix best practices

More ecosystem packages and updates are coming soon.

Full Docs

See fluttermix.com for complete guides, widget references, and migration resources.

What's Changed

  • docs: Add version selector and update navbar by @tilucasoli in #721
  • docs: Update animations guide introduction by @tilucasoli in #722
  • feat: Next release by @leoafarias in #714
  • chore: fix publish issues by @tilucasoli in #750
  • fix: lint issues and code formatting by @leoafarias in #752
  • style: apply code formatting across all packages by @leoafarias in #753
  • style: apply dart fix to example package by @leoafarias in #755
  • feat: Implement Widget Builder Pattern for Ergonomic Mix API by @leoafarias in #754
  • fix: Add default styles to Mix widgets by @leoafarias in #759
  • refactor: normalize mixin type parameter order for consistency by @leoafarias in #757
  • fix: modernize DCM pipeline with dcm-action@v2 and update deprecated GitHub Actions by @leoafarias in #756
  • fix: breakpoint fix by @tilucasoli in #758
  • refactor: remove redundant static builder methods from widgets by @leoafarias in #763
  • refactor: migrate StyleWidget to use styleSpec parameter for improved consistency by @leoafarias in #762
  • fix: widget state tracking logic in StyleBuilder by @tilucasoli in #765
  • refactor: remove unsupported widget state variants by @leoafarias in #768
  • feat: Add DefaultStyledText and DefaultStyledIcon typedefs by @tilucasoli in #767
  • refactor: extract widget state variant mixins into separate files by @leoafarias in #769
  • fix: VariantStyle merge by @tilucasoli in #774
  • refactor: API modification and update to Dart 3.10 by @tilucasoli in #776
  • docs: dot shorthand documentation by @tilucasoli in #777
  • chore: Remove Mix API reference markdown files by @tilucasoli in #778
  • docs: Improve widget docs and automate documentation generation by @tilucasoli in #780
  • refactor: Stack and StackBox by @tilucasoli in #779
  • docs: Add Mix tutorials and update documentation structure by @tilucasoli in #781
  • chore: Refactor CI, remove custom action, and rename example by @tilucasoli in #782
  • chore: move the examples to the root by @tilucasoli in #783
  • refactor: introduce Style.of() and Style.maybeOf() static methods by @leoafarias in #784
  • feat: add number directives and extension for numeric transformations by @leoafarias in #785
  • refactor: widget modifier API and update to Dart 3.10 by @tilucasoli in #775
  • fix: Ensure that Visibility Widget are visible until the end of animation by @dickermoshe in #771
  • fix: React Server Components RCE vulnerability by @vercel[bot] in #798
  • docs: refresh Mix 2.0 styler API and migration guide by @leoafarias in #793
  • Fix React Server Components RCE vulnerability by @vercel[bot] in #797
  • feat(mix): add applyVariants() method for NamedVariants by @leoafarias in #801
  • refactor: remove dead color mix and tighten tests by @leoafarias in #804
  • feat: deprecate $ utility accessors in favor of Styler classes by @leoafarias in #806
  • Add Flutter/FVM/DCM/Melos setup script by @leoafarias in #812
  • Fix SessionStart hook by adding required matcher field by @leoafarias in #813
  • Fix SessionStart hook path expansion and add defensive checks by @leoafarias in #814
  • Remove SessionStart hook and flutter env helper by @leoafarias in #815
  • test: strengthen scope dependency notifications by @leoafarias in #810
  • fix: add AnimationStyleMixin to FlexBoxStyler and StackBoxStyler by @leoafarias in #819
  • fix: add missing chain getter to StackStyler by @leoafarias in #818
  • Run setup script by @leoafarias in #820
  • fix: standardize specs with @immutable and fix equality bugs by @leoafarias in #821
  • fix: use symlinks for non-interactive shell support by @leoafarias in #822
  • docs: fix incorrect SDK version and deprecated API terminology by @leoafarias in #823
  • refactor: mark resolveProp as @internal and migrate to MixOps.resolve by @leoafarias in #833
  • refactor: adopt Dart 3.10 dot notation syntax in examples by @leoafarias in #836
  • feat(mix_generator): Add MixableSpec, MixableStyler, and code generation for properties by @tilucasoli in #835
  • chore: set up Claude Code for project by @leoafarias in #841
  • style: apply DCM and dart format improvements by @leoafarias in #843
  • docs: remove obsolete documentation by @leoafarias in #844
  • feat(mix_generator): Support Style class extensions in code generation by @tilucasoli in #845
  • feat(mix_annotations): Add setterType parameter to MixableField annotation by @tilucasoli in #846
  • fix: Make copyWith parameters nullable by @tilucasoli in #848
  • fix(mix_generator): Respect nullability in lerp and update deps by @tilucasoli in #849
  • docs: codegen for Mix specs and stylers by @tilucasoli in #850
  • feat: add loop animation support for Phase and Keyframe animations by @tilucasoli in #824
  • refactor(core): simplify StyleSpecBuilder build method by @tilucasoli in #825
  • docs: Add custom context variant example for shift key by @tilucasoli in #799
  • feat: add mix_tailwinds Tailwind utility layer (POC) by @leoafarias in #839
  • docs(website): add mix_tailwinds docs by @leoafarias in #851
  • docs: clarify focus state requires Pressable wrapper by @tilucasoli in #826
  • chore(examples,website): add Flutter preview embedding system by @leoafarias in #855
  • feat: add static factory constructors for styler dot-shorthand notation by @leoafarias in #857
  • fix(website): add Vercel build script for Flutter preview bundle by @leoafarias in #858
  • fix(mix): prevent animation drivers from resetting on unchanged config by @tilucasoli in #859
  • docs: Add animation examples; update previews & docs by @tilucasoli in #860
  • chore: dot shorthand updates across docs and examples by @leoafarias in #861
  • refactor: review all the docs and example codes by @tilucasoli in #863
  • docs: Complete mix_tailwinds documentation by @leoafarias in #864
  • docs(website): Complete mix_tailwinds documentation with preview by @leoafarias in #866
  • docs(website): add mix_schema ecosystem page by @leoafarias in #865
  • docs: update to dot-shorthand syntax across examples and documentation by @leoafarias in #868
  • docs: Update README.md by @tilucasoli in #872
  • chore: update Flutter version configuration to stable by @leoafarias in #873
  • chore: apply melos lint fixes by @leoafarias in #874
  • feat: Recreate mix_lint using analysis_server plugin by @tilucasoli in #871
  • Add repository-specific Copilot onboarding instructions with environment troubleshooting by @Copilot in #875
  • docs: Add example previews and embed FlutterPreview in docs by @tilucasoli in #876
  • docs: Update docs and preview examples by @tilucasoli in #877
  • chore(mix): remove deprecated APIs by @leoafarias in #870
  • docs: Revise preview examples and registry by @tilucasoli in #878
  • docs: remove banner by @tilucasoli in #879
  • docs: rename folder by @tilucasoli in #880
  • docs(website): improve UX, styling, and update dependencies by @leoafarias in #881
  • fix(mix): snap null matrix lerp endpoints by @leoafarias in #882
  • fix(mix): use new config duration in looping animation updateDriver by @leoafarias in #885
  • feat(mix): add static factory constructors for all styler instance methods by @tilucasoli in #884

New Contributors

Full Changelog: mix-1.7.0...mix-v2.0.1