converter - Convert between different units of measurement
A Dart library for converting between different units of measurement for various quantities
Usage
See example/main.dart
Length
final Length l1 = Length(2, 'm'); // 2 metres
final Length l2 = Length(37, 'cm'); // 37 centimetres
final Length l3 = Length(3.7, 'dm'); // 3.7 decimetres
final num l2ValueInInches = l2.valueIn('in');
// l2ValueInInches ~= 14.566929
final Length sum = l1 + l2;
// sum == 2370 millimetres
final Length difference = l1 - l2;
// difference ~= 5.347769 feet
final bool l1EQl2 = l1 == l2;
// l1EQl2 == false
final bool l2EQl3 = l2 == l3;
// l2EQl3 == true
final bool l1GTl2 = l1 > l2;
// l1GTl2 == true
final bool l1LTEl2 = l1 <= l2;
// l1LTEl2 == false
Time
final Time t1 = Time.si(86400); // 86400 seconds
final Time t2 = Time(24, 'h'); // 24 hours
final Time t3 = Time(1500, 'min'); // 1500 minutes
final num t3ValueInDays = t3.valueIn('d');
// t3ValueInDays ~= 1.041667
final Time sum = t1 + t2;
// sum == 2880 minutes
final Time difference = t3 - t2;
// difference == 3600 seconds
final bool t1EQt2 = t1 == t2;
// t1EQt2 == true
final bool t2EQt3 = t2 == t3;
// t2EQt3 == false
final bool t3GTt2 = t3 > t2;
// t3GTt2 == true
final bool t3LTEt2 = t3 <= t2;
// t3LTEt2 == false
Supported quantities and units
Length
m- metre (SI)dm- decimetrecm- centimetremm- millimetreµm- micrometrenm- nanometredam- decametrehm- hectometrekm- kilometreMm- megametreGm- gigametreÅ- ångströmin- inchft- footyd- yardmi- milenmi- nautical mile
Mass
kg- kilogram (SI)hg- hectogramdag- decagramg- gramdg- decigramcg- centigrammg- milligramµg- microgramng- nanogramMg- megagramGg- gigagramoz- ouncelb- poundt- tonne or metric tonlong-ton|ton- long ton or imperial tonshort-ton- short ton
Time
s- second (SI)ds- decisecondcs- centisecondms- millisecondµs- microsecondns- nanoseconddas- decasecondhs- hectosecondks- kilosecondMs- megasecondGs- gigasecondmin- minuteh- hourd- daywk- weekfn- fortnightmo- monthy- yeardec- decadec- century
ElectricCurrent
A- ampere (SI)mA- milliamperekA- kiloamperestatA- statampereabA|Bi- abampere or biot
Temperature
K- kelvin (SI)C- degree CelsiusF- degree FahrenheitR- degree Rankine
Acceleration
m/s2- metre per second squared (SI)cm/s2|gal- centimetre per second squared or galileoft/s2- foot per second squaredg- standard gravity
Area
m2- square metre (SI)dm2- square decimetrecm2- square centimetremm2- square millimetreµm2- square micrometredam2- square decametrehm2|ha- square hectometre or hectarekm2- square kilometreMm2- square megametrein2- square inchft2- square footmi2- square mileac- acre
ElectricCharge
C- coulomb (SI)mC- millicoulombµC- microcoulombnC- nanocoulombAh- ampere hourmAh- milliampere hourstatC|Fr- statcoulomb or franklinabC- abcoulomb
Force
N- newton (SI)dyn- dynegf- gram-forcekgf- kilogram-forcelbf- pound-forcepdl- poundal
Frequency
Hz- hertz (SI)kHz- kilohertzMHz- megahertzGHz- gigahertzTHz- terahertzrad/s- radian per seconddeg/s- degree per secondrpm- revolutions per minute
PlaneAngle
rad- radian (SI)mrad- milliradiandeg- degreearcmin- arcminutearcsec- arcsecondgrad- gradian
SolidAngle
sr- steradian (SI)deg2- square degree
Speed
m/s- metre per second (SI)km/h- kilometre per hourft/s- foot per secondmi/h- mile per hourkn- knot
Volume
m3|kl- cubic metre or kilolitre (SI)dm3|l- cubic decimetre or litrecm3|ml- cubic centimetre or millilitremm3|µl- cubic millimetre or microlitredam3|Ml- cubic decametre or megalitrehm3|Gl- cubic hectometre or gigalitrekm3|Tl- cubic kilometre or teralitrein3- cubic inchft3- cubic footmi3- cubic milegal- gallonqt- quartpt- pintfl-oz- fluid ouncetbsp- tablespoontsp- teaspoon
Syntax
See documentation for more
