dtcg_theme 0.7.1
dtcg_theme: ^0.7.1 copied to clipboard
Turns W3C Design Tokens (DTCG) files into a type-safe Flutter theme: a ThemeExtension per mode, and a build that fails on a broken reference or a pair below your WCAG target.
0.7.1 #
- The README's badge row, which every other package in this publisher has and this one did not. pub.flutter-io.cn renders the README of the version it holds, so a release is the only way to show it. No code changed.
0.7.0 #
Added #
- The
transitioncomposite becomes a small immutable class written beside the tokens (AppTokensTransition), holding the duration, the delay and the curve together. Flutter has no type for one, and three loose tokens let the duration and the curve drift apart in review. $deprecatedbecomes@Deprecatedon the generated field, with the reason. A group may deprecate everything under it. The generated file silences the warning about itself, since its own constants touch every field.--watchregenerates on every save, survives a momentarily broken file, and picks up a mode added to the configuration without a restart.strokeStyleis refused with the reason - Flutter'sBorderStyleis solid or nothing - rather than as one more name in a list of unsupported types.- CI, and an example README that is no longer the
flutter createtemplate.
Fixed #
- String literals in the generated file now escape
$. A font family or a description containing one produced a file that either would not compile or compiled into an unintended interpolation. --checkreports a missing token file the way the generator does, instead of aFileSystemExceptionstack trace.- Two
dart docwarnings: Flutter types are named in backticks, because this package deliberately does not depend on Flutter for dartdoc to link them.
0.6.0 #
Added #
- A
contrastblock checks colour pairs against WCAG 2.1 in every mode, before a line of Dart is written.leveltakesAA,AA-large,AAA,AAA-large, or a ratio of your own; a failure names the mode, the pair and both numbers. A translucent foreground is composited over its background first, so it is measured as it will be seen. This is what catches the pair that is readable in light and grey on grey in dark. - The
bordercomposite type becomes aBorderSide, interpolated withBorderSide.lerp.stylemust besolid: Flutter'sBorderSidedraws nothing else, so a dashed border stops the build rather than quietly coming out solid.
0.5.0 #
Added #
- Colours in any CSS Color 4 space:
oklch,oklab,lab,lch,hsl,hwb,display-p3,rec2020,a98-rgb,prophoto-rgb,xyz-d50,xyz-d65and the two sRGB forms. They are converted to sRGB at generation time, because that is what Flutter paints; out of gamut colours are clipped, and nohexfallback is needed any more. - Radial and sweep gradients, chosen through
$extensions:{"dtcg_theme": {"shape": "radial", "center": "topCenter", "radius": 0.9}}. A sweep takesstartAngleandendAnglein degrees. An unknown shape lists the real ones. - Figma Variables and Tokens Studio exports are normalised before parsing:
unprefixed
type/value, their type names,SemiBold-style weights,xandyshadow offsets, percentage line heights,AUTOdropped,$themesand$metadataignored. A multi-set Tokens Studio file names its sets in the error, and a configured path picks one withtokens.json#global. These dialects are written from the documented formats and are not yet verified against a real export from either tool. - Maths in a token value (
"{spacing.base} * 2","rgba({c}, 0.5)") is refused by name, rather than reaching the resolver as a string that means nothing. So is an inner shadow, which a FlutterBoxShadowcannot draw.
Changed #
- A generated gradient field is now typed
Gradient, notLinearGradient, and interpolated withGradient.lerp- a token may be linear in one mode and radial in another. Regenerate to pick this up; code that assigns the field to aBoxDecoration.gradientneeds no change.
0.4.0 #
Added #
- A
text_themeblock generates aTextThemeper mode from typography tokens, soThemeData(textTheme: AppTokens.light.textTheme)needs no hand-written mapping. A slot that is not one of the fifteen Material slots, or that points at something other than atypographytoken, stops the build. - Gradients can state a direction through the spec's
$extensions:{"dtcg_theme": {"begin": "topLeft", "end": "bottomRight"}}, taking the names of Flutter'sAlignmentconstants. An unknown name lists the real ones.
Changed #
- The emitter composes generated members - the colour scheme, the text theme - from one list instead of threading each through the six places a member appears. No change to the output; the golden test held throughout.
0.3.0 #
Added #
- A
color_schemeblock in the configuration generates aColorSchemeper mode, next to the tokens, soThemeData(colorScheme: AppTokens.light.colorScheme)needs no hand-written mapping. It is interpolated bylerplike everything else. - Brightness follows the mode name, and a
brightnessblock can state it outright. - The build stops when a required slot is missing, when a slot points at a token no mode defines, or when it points at something that is not a colour - each message naming the slot and the token.
0.2.0 #
Added #
gradienttokens become aLinearGradient, aliases in the stops included.- Colours may use the spec's object form,
{colorSpace, components, alpha}, with ahexfallback preferred when present. An unsupported colour space is named in the error, along with the way out.
Changed #
- A
shadowtoken now generates aList<BoxShadow>rather than a singleBoxShadow, so a token can hold layered shadows - and it matches what Flutter'sboxShadowtakes. A single shadow becomes a one element list.
0.1.0 #
First release.
- Reads W3C DTCG token files:
color,dimension,number,duration,fontFamily,fontWeight,cubicBezier, and the compositetypographyandshadow. - Resolves aliases, including inside composite tokens, and infers a token's type from what its alias points at.
- Layers mode files over a base, generating one constant per mode.
- Generates a
ThemeExtensionwithcopyWith, a type-appropriatelerpandof/maybeOflookups. - Every token becomes a type Flutter already has, so the generated file needs no runtime library.
- Refuses to build on unresolved references, alias cycles, untyped tokens, bad values, modes that disagree and colliding field names - each message naming the file and the token path.
--checkfails when the checked-in file is out of date, for CI.- No analyzer dependency: the emitter formats its own output, so the package
cannot clash with the
metaversion the Flutter SDK pins.