quantity
Facilitates working with physical quantities such as angles, lengths, masses, temperatures and many others. Supports uncertainty and arbitrary precision.
5.0.0
5.0K downloads/mo
#3830 most downloaded on pub.dev
cooler-king/quantity
What this package is like to depend on
Last release 2 months ago
01 Jun 2026
Release timing varies
gaps range from 2 weeks to 2.8 years
Nearly every release is documented
notes for 16 of 17 stable releases
Nothing withdrawn
no release was ever pulled
11 years old
17 releases · first in 2015
1 release in the last 12 months
see the full history below
Release timeline
17 releases · Oct 2015 to Jun 2026
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
Releases
latest 17-
5.0.001 Jun 2026Release notes
Open source →- Dart 3+ Modernization: Applied
sealed,base, andfinalmodifiers toNumber,Quantity, andDimensionsclasses. Refactored map parsing and type determination using modern pattern matching and switch expressions.- Fluent DX & Unit Shortcuts: Added extension getters on
numandNumber(e.g.,5.meters,75.tps) and unit shortcuts (inKilometers,inTps,inCelsius). - Registry Decoupling & Tree-Shaking: Decoupled the physical quantity registry by registering subclasses dynamically, allowing for clean tree-shaking. Added a lightweight core entrypoint
lib/quantity_core.dart. - JSON Serialization: Added full
toJson()andfromJson()support toQuantity,Number, andDimensionshierarchies. - Decimal Interoperability: Integrated the
decimalpackage directly, introducingvalueSIAsDecimal,toDecimal(), andfromDecimal(Decimal)to allow high-precision decimal operations. - NIST Constants Sync: Added an automated script
bin/update_nist_constants.dartto synchronize physical constants and uncertainties with the official NIST CODATA table. - AI Readiness & Natural Language Processing:
- Added
Quantity.parse(String text)for parsing natural language physical measurements (e.g.,'120 km/h','9.8 m/s^2'). - Added
Quantity.checkDimensionalConsistencyto symbolically check math formula consistency (e.g.,s = u * t + 0.5 * a * t^2). - Added
Dimensions.describereturning human-readable dimensions (e.g.'Length^1 / Time^2'). - Exposed structured JSON schemas (
Quantity.jsonSchema) for structured LLM function calling.
- Added
- Computational & Digital Layout Quantities:
- Introduced
TokenandTokenRateclasses to support modeling, parsing, and arithmetic for NLP/LLM context tracking and throughput metrics. - Introduced
Pixel,Resolution(pixels per length), andPixelDensity(pixels per area) classes to support spatial layout scaling, screen resolution calibration (PPI/DPI/DPCM), and graphics calculations with type-safe arithmetic operators.
- Introduced
- Synonym Quantity Types: Added compile-time typedef aliases and dynamic runtime name registry mapping for 19 physical quantity synonyms across 12 distinct classes (e.g.
Irradiance/EnergyFluxDensity/PowerFluxDensitysynonymizingHeatFluxDensity,StresssynonymizingPressure,WorksynonymizingEnergy, etc.). - Domain Collections: Added six domain library collections under
lib/domain/to group quantity types, units, and constants commonly encountered in specific fields:radiometry,atomic_nuclear,computing,chemistry,acoustics, andfluid_dynamics. Added corresponding unit tests for each domain. - Algebraic Property Verification: Established property-based testing for
Dimensionsalgebra. - Test Coverage Boost: Significantly expanded unit test coverage across the package. Wrote comprehensive tests for previously untested parts including the
Fractionnumber representation class, trig functions and constants inangle_ext, fluent utility extensions onnumandNumber, and verified variable mappings across all 40+ extension libraries. Further expanded coverage by testing astronomical time scale conversions, range math, exception string serialization, logarithmic level operations, and dynamically generated Unit constructors/derivatives across all 75+ physical quantity classes. Raised overall repository code coverage to 90.7% (surpassing the targets of 70% and 85%).
- Fluent DX & Unit Shortcuts: Added extension getters on
- Dart 3+ Modernization: Applied
-
4.0.027 Nov 2024Release notes
Open source →- Breaking changes:
- Changed some compound unit constructor names to be more descriptive.
- Made
Units.singularproperty non-nullable. - Number
==operators now take anObjectargument instead ofdynamic, - Updated the minimum
intldependency to0.19.0. - Added unit tests for all compound unit constructors.
- Fixed numerous bugs in compound unit constructor logic.
- Accounted for lower case
ein number formatting/grouping. - Removed logging of quantity type resolution failure from
inversemethod. - Updated formatting; addressed pana suggestions.
- Breaking changes:
-
3.0.210 Dec 2023 -
3.0.124 Nov 2023 -
3.0.007 Jul 2023 -
2.0.107 Jul 2023 -
2.0.013 Mar 2021 -
1.0.006 Oct 2020Release notes
Open source →- Requires >= Dart SDK 2.3.
- Increased testing.
- Number formatting; quantity text output.
- The latest official constants.
- TimeInstant extensions.
- MutableQuantity.
- Requires >= Dart SDK 2.3.
-
0.3.022 Jan 2020 -
0.2.006 Aug 2018Nothing published for this version
-
0.2.0+106 Aug 2018Release notes
Open source →- Dart 2 support.
- Stricter typing.
- Addressed many (but not all) analyzer items.
- Dart 2 support.
-
0.1.423 Oct 2015Release notes
Open source →- Added
isScalarandisScalarSItoDimensionsandQuantity.- Extended use of type hints in dimensions for more efficient and accurate type determination during operations.
- Generalized special handling of scalar quantities.
- Added
-
0.1.323 Oct 2015Release notes
Open source →- Added
operator ==andhashCodeto quantity range classes.- Added
toTypedQuantitytoMiscQuantity. - Changed
googolconstant to arbitrary precision. - Renamed private
_dimensionsconstructor to_internalin quantities.
- Added
- Added
-
0.1.3+123 Oct 2015 -
0.1.205 Oct 2015Release notes
Open source →PreciseisIntegerand_limitPrecisionfixes.hashCodetesting for quantity objects (esp.Scalar)
-
0.1.104 Oct 2015 -
0.1.003 Oct 2015