carpenter_units 0.2.0 copy "carpenter_units: ^0.2.0" to clipboard
carpenter_units: ^0.2.0 copied to clipboard

Typed physical UI units for Carpenter tooling and runtimes.

carpenter_units #

A small, pure-Dart library for typed physical UI quantities. It has no knowledge of widgets, themes, tokens, or semantic roles.

final spacing = Unit.parse('1.25rem'); // Rem(1.25)
final duration = Unit.parse('200ms');  // Milliseconds(200)

Supported units are px, rem, em, ms, and s. Values serialize in a deterministic canonical form:

const Rem(1.0).canonical; // '1rem'
const Seconds(.5).canonical; // '0.5s'

Length resolution is explicit. em deliberately fails when the local font size is unavailable:

const context = LengthUnitContext(rootFontSize: 16, currentFontSize: 20);
const Rem(1.25).resolve(context); // 20 logical px
const Em(.5).resolve(context); // 10 logical px

Time values use deterministic rounding to Dart microseconds:

const Seconds(.2).toDuration(); // Duration(milliseconds: 200)

0.2.0 replaces the experimental Flutter UnitsRoot cascade with this pure-Dart API. Flutter-specific scoping belongs to a higher-level runtime.

License #

Apache License 2.0. See LICENSE.

1
likes
0
points
253
downloads

Publisher

verified publisheralbizia.studio

Weekly Downloads

Typed physical UI units for Carpenter tooling and runtimes.

Repository (GitHub)
View/report issues

Topics

#units #design-system

License

unknown (license)

More

Packages that depend on carpenter_units