dtcg_theme 0.7.1 copy "dtcg_theme: ^0.7.1" to clipboard
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 transition composite 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.
  • $deprecated becomes @Deprecated on 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.
  • --watch regenerates on every save, survives a momentarily broken file, and picks up a mode added to the configuration without a restart.
  • strokeStyle is refused with the reason - Flutter's BorderStyle is 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 create template.

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.
  • --check reports a missing token file the way the generator does, instead of a FileSystemException stack trace.
  • Two dart doc warnings: 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 contrast block checks colour pairs against WCAG 2.1 in every mode, before a line of Dart is written. level takes AA, 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 border composite type becomes a BorderSide, interpolated with BorderSide.lerp. style must be solid: Flutter's BorderSide draws 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-d65 and 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 no hex fallback is needed any more.
  • Radial and sweep gradients, chosen through $extensions: {"dtcg_theme": {"shape": "radial", "center": "topCenter", "radius": 0.9}}. A sweep takes startAngle and endAngle in 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, x and y shadow offsets, percentage line heights, AUTO dropped, $themes and $metadata ignored. A multi-set Tokens Studio file names its sets in the error, and a configured path picks one with tokens.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 Flutter BoxShadow cannot draw.

Changed #

  • A generated gradient field is now typed Gradient, not LinearGradient, and interpolated with Gradient.lerp - a token may be linear in one mode and radial in another. Regenerate to pick this up; code that assigns the field to a BoxDecoration.gradient needs no change.

0.4.0 #

Added #

  • A text_theme block generates a TextTheme per mode from typography tokens, so ThemeData(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 a typography token, stops the build.
  • Gradients can state a direction through the spec's $extensions: {"dtcg_theme": {"begin": "topLeft", "end": "bottomRight"}}, taking the names of Flutter's Alignment constants. 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_scheme block in the configuration generates a ColorScheme per mode, next to the tokens, so ThemeData(colorScheme: AppTokens.light.colorScheme) needs no hand-written mapping. It is interpolated by lerp like everything else.
  • Brightness follows the mode name, and a brightness block 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 #

  • gradient tokens become a LinearGradient, aliases in the stops included.
  • Colours may use the spec's object form, {colorSpace, components, alpha}, with a hex fallback preferred when present. An unsupported colour space is named in the error, along with the way out.

Changed #

  • A shadow token now generates a List<BoxShadow> rather than a single BoxShadow, so a token can hold layered shadows - and it matches what Flutter's boxShadow takes. 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 composite typography and shadow.
  • 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 ThemeExtension with copyWith, a type-appropriate lerp and of / maybeOf lookups.
  • 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.
  • --check fails 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 meta version the Flutter SDK pins.
0
likes
160
points
109
downloads

Documentation

API reference

Publisher

verified publisherbomsamdi.com

Weekly Downloads

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.

Repository (GitHub)
View/report issues

Topics

#design-tokens #theme #codegen #figma #accessibility

License

MIT (license)

Dependencies

args, yaml

More

Packages that depend on dtcg_theme