quantify 0.15.0
quantify: ^0.15.0 copied to clipboard
Type-safe unit converter. Convert length, mass, temperature, speed, energy, pressure and 20+ physical quantities with compile-time safety, elegant extension syntax and constants.
Changelog #
All notable changes to the quantify package will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
0.15.0 #
2026-02-23
Added #
-
New Quantity:
TemperatureDelta— a dedicated type for temperature changes (intervals), distinct from absoluteTemperaturepoints.TemperatureDeltaUnitenum with four linear units:kelvinDelta,celsiusDelta,fahrenheitDelta,rankineDelta.- Factors:
kelvinDelta=celsiusDelta= 1.0 K;fahrenheitDelta=rankineDelta= 5/9 K. - Full arithmetic:
TemperatureDelta + TemperatureDelta,- TemperatureDelta,* scalar,/ scalar. - Convenience extensions on
num:20.celsiusDelta,18.fahrenheitDelta,10.kelvinDelta,9.rankineDelta. - Value getters on
TemperatureDelta:inKelvinDelta,inCelsiusDelta,inFahrenheitDelta,inRankineDeltaandas*conversion variants. - Interop extension
TemperatureDeltaTemperatureInteropprovidingdelta.addTo(temperature)for the commutative form of heating. - Available via
package:quantify/quantify.dartor the new granularpackage:quantify/temperature_delta.dart.
-
Temperature.asDeltagetter — converts an absolute temperature to aTemperatureDeltarelative to absolute zero (always inkelvinDelta). Useful for formulas that require a Kelvin scalar magnitude, such as the ideal gas law or Boltzmann energy calculations. -
Temperature.ratioTo(Temperature other)— replacesoperator /for temperature ratios. Always converts both operands to Kelvin before dividing, ensuring thermodynamic validity regardless of the input scale (e.g.300.celsius.ratioTo(200.celsius)gives573.15 / 473.15, not3/2). ThrowsArgumentErrorif the divisor is absolute zero. -
Temperature.operator +(TemperatureDelta delta)— adds a delta to an absolute temperature, returning a newTemperaturein the same unit. Models heating. -
Temperature.subtract(TemperatureDelta delta)— subtracts a delta from an absolute temperature, returning a newTemperature. Named method (not an operator) becauseoperator -is reserved forTemperature - Temperature. Equivalent totemp + (delta * -1.0).
Changed — Breaking #
-
Temperature.operator -(Temperature other)now returnsTemperatureDelta(previously returneddouble). The result's unit mirrors the LHS unit (e.g. subtracting two Celsius temperatures yields acelsiusDelta).Migration: replace
double diff = t2 - t1;withdouble diff = (t2 - t1).inKelvinDelta;(or.inCelsiusDelta, etc.). -
Temperature.operator /removed. Usetemperature.ratioTo(other)instead. The new method always uses Kelvin, making the ratio physically meaningful for all input scales.Migration: replace
t2 / t1witht2.ratioTo(t1). -
EngineeringConstants.thermalExpansionnow acceptsTemperatureDeltainstead ofTemperature. The previous signature would apply the Kelvin affine offset to what should be a plain delta, producing results up to ~14× too large for typical Celsius inputs.Migration: replace
20.celsiuswith20.celsiusDelta, or pass the result oft2 - t1directly (it is now aTemperatureDelta). -
EngineeringConstants.conductiveHeatTransfernow acceptsTemperatureDeltainstead ofTemperature, for the same reason.Migration: replace
const Temperature(10, TemperatureUnit.kelvin)with10.kelvinDelta.
Fixed #
thermalExpansionandconductiveHeatTransferno longer misinterpret a temperature difference as an absolute temperature, eliminating a silent calculation error where20.celsiuswas internally treated as 293.15 K.
0.14.1 #
2026-02-20
Fixed #
- Quick Start code example had an undeclared variable that prevented compilation.
- Removed unused duplicate imports in mass conversion factors.
- Example project SDK constraint now matches the main package requirement (>=3.5.0).
Changed #
- Standardized barrel file exports for density and specific_energy to match other quantities. Removed unintended public export of internal factor constants.
0.14.0 #
2026-02-11
Added #
- Energy: International Table (IT) Calorie Variants:
- Added
EnergyUnit.calorieITandEnergyUnit.kilocalorieITfor International Table calorie (4.1868 J). - New extensions:
.calIT,.kcalIT,.caloriesIT,.kilocaloriesITfor creating Energy instances. - New getters:
.inCaloriesIT,.inKilocaloriesIT,.asCaloriesIT,.asKilocaloriesITfor conversions. - Existing
calorieandkilocalorieunits continue to use the thermochemical calorie (4.184 J) as the IUPAC/ISO standard.
- Added
Changed #
- Improved Pressure Unit Conversion Accuracy:
- Distinguished between Torr and mmHg (millimeter of mercury) for higher precision.
Torris now defined as exactly 1/760 of a standard atmosphere (101325/760 Pa).mmHguses the conventional value based on actual mercury density at 0°C (133.322387415 Pa).- The difference is approximately 0.000019 Pa, significant for high-precision scientific applications.
- Updated inHg (inch of mercury) conversion to be based on mmHg rather than Torr for consistency with scientific standards (NIST SP 811).
- Distinguished between Torr and mmHg (millimeter of mercury) for higher precision.
0.13.0 #
2026-01-12
- New Quantity: Density: Support for
kg/m³,g/cm³,g/mL. - New Quantity: Specific Energy: Support for
J/kg,Wh/kg,kWh/kg,kJ/kg. - Volume: Added
centiliter(cl) unit. - Improved: Complete unit tests for new quantities.
0.12.0 #
2025-08-11
Added #
- Major Feature: Comprehensive Constants Library.
- A library of over 100 type-safe constants, organized into three categories: PhysicalConstants, AstronomicalConstants, and EngineeringConstants.
- Constants are represented as Quantity objects wherever possible (e.g., PhysicalConstants.speedOfLight is a Speed object, AstronomicalConstants.standardGravity is an Acceleration object).
- Added convenience methods for common scientific and engineering formulas, such as PhysicalConstants.photonEnergy(), AstronomicalConstants.escapeVelocity(), and EngineeringConstants.mechanicalStress().
- Constants are accessible via a new, separate import: package:quantify/constants.dart.
0.11.0 #
2025-07-27
Changed #
- Conceptual Refinement of
FrequencyandAngularVelocity:Frequencyis now the comprehensive quantity for all periodic units (inverse time, T⁻¹), including rotational rates.AngularVelocityremains a distinct, specialized type for rotational mechanics to ensure semantic type safety.
Added #
FrequencyUnit Expansion: Addedrad/s(radian per second) anddeg/s(degree per second) toFrequency.- Interoperability Between
FrequencyandAngularVelocity:- Added a safe
.asFrequencygetter toAngularVelocityfor direct conversion to aFrequencyobject. - Added a guarded
.asAngularVelocitygetter toFrequencythat only converts compatible rotational units (rpm,rad/s,Hz, etc.) and throws anUnsupportedErrorfor non-rotational units (likebpmorMHz), preventing logical errors in calculations.
- Added a safe
0.10.0 #
2025-07-26
-
New Quantities:
EnergyandPower- Added the
Energyquantity with common units (J, kJ, MJ, kWh, kcal, eV, Btu). - Added the
Powerquantity with a comprehensive set of SI, engineering, and CGS units (W, kW, MW, GW, hp, PS, Btu/h, erg/s).
- Added the
-
Expanded Unit Coverage
- Added new units to
Acceleration(cm/s²),Force(gf, pdl), andElectricCharge(mAh, statC, abC)
- Added new units to
0.9.0 #
2025-07-22
- Added relational operators (
>,<,>=,<=) for all quantities. Comparisons are now more readable (e.g.,1.m > 99.cm). - Added
isEquivalentTo()method for explicit magnitude equality checks (e.g.,1.m.isEquivalentTo(100.cm)).
0.8.0 #
2025-07-22
- New Derived Quantities
Frequencywith units (Hz,MHz,GHz,THz,rpm, etc.).ElectricChargewith units (C,Ah,e,µC, etc.).SolidAnglewith units (sr,deg²,sp).
0.7.0 #
2025-07-16
- New Derived Quantity
Areawith units (m²,km²,ha,acre,yd²,ft², etc.).Volumewith comprehensive SI, US customary, and cooking units (m³,L,gal,fl-oz,tsp, etc.).
0.6.0 #
2025-07-05
- New Derived Quantities
Speed: Addedm/s,km/h,mph,kn,ft/s.Acceleration: Addedm/s²,g(standard gravity),km/h/s.Force: AddedN(Newton),lbf,dyn,kgf,kN.
0.5.0 #
2025-06-29
Added #
-
Expanded Unit Coverage:
- Length: Added Mm (megametre) and Gm (gigametre).
- Mass: Added Mg (megagram) and Gg (gigagram).
- Time: Added full range of SI prefixes (Gs to cs) and calendar units (fortnight, decade, century).
- ElectricCurrent: Added CGS units statA (statampere) and abA (abampere/biot).
-
Granular Exports: Added separate library entry points (e.g., package:quantify/length.dart) to allow for explicit imports and prevent namespace conflicts.
0.4.0 #
2025-06-23
Added #
-
New Quantity:
AngleAnglequantityAngleUnit:radian(rad): The SI-derived unit, used as the base for conversions.degree(°): The most common unit for angles.gradian(grad): Unit used in surveying (400 grad in a circle).revolution(rev): Represents a full circle or turn.arcminute('): High-precision unit (1/60 of a degree).arcsecond("): High-precision unit (1/60 of an arcminute).milliradian(mrad): Common in optics and ballistics.
- Standard arithmetic operators (
+,-,*,/) forAngle.
-
New Quantity:
AngularVelocityAngularVelocityquantity - represents rotational speed.AngularVelocityUnit:radianPerSecond(rad/s): The SI-derived unit.degreePerSecond(°/s).revolutionPerMinute(rpm): A widely used unit for rotational speed.revolutionPerSecond(rps).
- Standard arithmetic operators for
AngularVelocity.
0.3.0 #
2025-06-21
Added #
- Expanded Unit Coverage:
- Length:
- SI Prefixes:
hm(hectometer),dam(decameter),dm(decimeter),μm(micrometer),nm(nanometer),pm(picometer),fm(femtometer). - Astronomical:
AU(astronomical unit),ly(light year),pc(parsec). - Special:
Å(ångström).
- SI Prefixes:
- Mass:
- SI Prefixes:
hg(hectogram),dag(decagram),dg(decigram),cg(centigram),μg(microgram),ng(nanogram). - Imperial/US:
short ton,long ton. - Special:
u(atomic mass unit),ct(carat).
- SI Prefixes:
- Time:
- SI Prefixes:
μs(microsecond),ns(nanosecond),ps(picosecond). - Calendar:
wk(week),mo(month),yr(year).
- SI Prefixes:
- Temperature:
- Absolute Scale:
°R(rankine).
- Absolute Scale:
- Length:
0.2.0 #
2025-06-16
Added #
- New SI Base Quantity Types (completing all 7 SI base units):
- Mass:
Massclass andMassUnitenum (kg,g,mg,t(tonne),lb,oz,st(stone),slug).
- Amount of Substance (Molar Amount):
MolarAmountclass andMolarUnitenum (mol,mmol,µmol,nmol,pmol,kmol).
- Electric Current:
Currentclass andCurrentUnitenum (A,mA,µA,nA,kA).
- Luminous Intensity:
LuminousIntensityclass andLuminousIntensityUnitenum (cd,mcd,kcd).
- Mass:
0.1.0 #
2025-06-12
Added #
- Initial Release of
quantifyv0.1.0 - Core Functionality:
- Type-safe
Quantitybase class for representing physical quantities with a value and a unit. Unitinterface for defining conversion factors and symbols.- Immutable
Quantityobjects. doubleprecision for quantity values.- Elegant API with extension methods on
numfor quantity creation (e.g.,10.m,20.celsius). - Extension methods on
Quantityfor easy value retrieval in target units (e.g.,length.inKm) and for obtaining newQuantityobjects in target units (e.g.,length.asKm). - Configurable
toString()method onQuantityobjects supporting:- Conversion to a
targetUnitbefore formatting. - Fixed
fractionDigits. - Option to
showUnitSymbol. - Custom
unitSymbolSeparator. - Locale-aware number formatting via
localeparameter (usingintlpackage). - Full control over number formatting via
numberFormatparameter (usingintlpackage).
- Conversion to a
- Arithmetic operations (
+,-,*by scalar,/by scalar) for most quantities. - Specialized arithmetic for
Temperature(differenceT - Treturnsdouble, ratioT / Treturnsdouble). Comparableinterface implementation for sorting quantities by magnitude.==operator override for value and unit equality.
- Type-safe
- Supported Quantity Types (with units and extensions):
- Length: Meter (m), Kilometer (km), Centimeter (cm), Millimeter (mm), Inch (in), Foot (ft), Yard (yd), Mile (mi), Nautical Mile (nmi).
- Time: Second (s), Millisecond (ms), Minute (min), Hour (h), Day (d).
- Temperature: Kelvin (K), Celsius (°C), Fahrenheit (°F). Handles affine conversions correctly.
- Pressure: Pascal (Pa), Atmosphere (atm), Bar (bar), PSI (psi), Torr, mmHg, inHg, kPa, hPa, mbar, cmH₂O, inH₂O.
