Skip to content

feat(mix): accept transform in gradient shorthands - #1073

Merged
tilucasoli merged 1 commit into
mainfrom
feat/gradient-shorthand-transform
Oct 1, 2026
Merged

tilucasoli merged 1 commit into
mainfrom
feat/gradient-shorthand-transform

Conversation

@leoafarias

Copy link
Copy Markdown
Collaborator

Summary

linearGradient, radialGradient, sweepGradient and the three foreground*Gradient shorthands on DecorationStyleMixin now take an optional GradientTransform? transform. It is passed straight to the matching LinearGradientMix, RadialGradientMix or SweepGradientMix. The generated BoxStyler, FlexBoxStyler, StackBoxStyler and WrapBoxStyler factories were regenerated and forward it too.

Before, spinning a gradient (for example a GradientRotation driven by a keyframe track) meant dropping to gradient(SweepGradientMix(...)), even though every gradient Mix type already supports transform.

style.sweepGradient(
  colors: [Colors.cyan, Colors.purple, Colors.cyan],
  transform: GradientRotation(angle),
)

Why extend the shorthand instead of deprecating it

  • These shorthands are not deprecated and do not appear under "Retired Conveniences" in skills/mix/references/styler-api-policy.md. They are grouped, nullable-argument conveniences, which the policy keeps.
  • They already forward stops and tileMode. transform was the only gradient field they did not expose, so this change makes them complete rather than adding a new kind of API.

Changes

  • decoration_style_mixin.dart: adds transform to all six gradient shorthands, with doc notes.
  • Regenerated *_spec.g.dart factories for Box, FlexBox, StackBox and WrapBox.
  • Tests in box_style_factory_test.dart: each shorthand resolves with the given transform; the result equals the explicit gradient(...Mix(transform: ...)) form; static factories match the instance methods; omitting transform leaves it null.
  • Docs: skills/mix/references/fluent-api.md table, and a "Spinning a gradient" keyframe example in animations.md. The example was checked with a temporary widget test that was not committed.
  • CHANGELOG: new Unreleased entry.

Additive and non-breaking: existing calls are unchanged.

Validation

  • fvm flutter test in packages/mix: 2986 tests passed
  • fvm dart analyze packages/mix: no errors or warnings. The 7 prefer_initializing_formals infos are all in files this PR does not touch.
  • dart format: clean

@leoafarias
leoafarias changed the base branch from main to fix/animation-config-removal September 29, 2026 04:13
@leoafarias
leoafarias force-pushed the feat/gradient-shorthand-transform branch from 28b84b4 to ca765d2 Compare September 29, 2026 04:13
@leoafarias
leoafarias added this pull request to stack #1075 September 29, 2026 04:13
@leoafarias leoafarias mentioned this pull request Sep 29, 2026
3 of 4 tasks
@tilucasoli
tilucasoli force-pushed the feat/gradient-shorthand-transform branch 2 times, most recently from 5ec5473 to 0430023 Compare September 29, 2026 13:20
@leoafarias
leoafarias force-pushed the feat/gradient-shorthand-transform branch from 0430023 to a7bc0a4 Compare September 29, 2026 15:36
@tilucasoli
tilucasoli force-pushed the feat/gradient-shorthand-transform branch 2 times, most recently from f28c871 to c3b0186 Compare October 1, 2026 02:57
Base automatically changed from fix/animation-config-removal to main October 1, 2026 03:09
linearGradient, radialGradient, sweepGradient and their foreground
counterparts now take an optional GradientTransform, forwarded to the
underlying LinearGradientMix/RadialGradientMix/SweepGradientMix. Rotating a
gradient (for example GradientRotation driven by a keyframe track) no longer
requires dropping to gradient(SweepGradientMix(...)). The generated
BoxStyler, FlexBoxStyler, StackBoxStyler and WrapBoxStyler factories pick up
the parameter via regeneration.
@tilucasoli
tilucasoli force-pushed the feat/gradient-shorthand-transform branch from c3b0186 to 050b72b Compare October 1, 2026 03:09
@tilucasoli
tilucasoli merged commit 77a462e into main Oct 1, 2026
12 checks passed
@tilucasoli
tilucasoli deleted the feat/gradient-shorthand-transform branch October 1, 2026 03:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants