Search packages, repositories and app categories

Package detailsv0.4.0

converter

A Dart library for converting between different units of measurement for various quantities

AndroidiOSWebmacOSWindowsLinux
30-day downloads
13.9K
Likes
22
Pub points
140

Install package

flutter pub add converter

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

The converter package is a Dart library designed to simplify unit conversion across various physical quantities such as length, weight, temperature, and more. It provides a clean, intuitive API for converting between different units within the same category, ensuring accuracy and ease of use in applications requiring measurement transformations. Built with cross-platform support, it works seamlessly on Android, iOS, Web, macOS, Windows, and Linux. Ideal for apps involving calculators, fitness tracking, or scientific tools.

Use cases

  • Unit conversion in calculators
  • Fitness and health tracking apps
  • Scientific and engineering applications
  • Travel apps with metric/imperial conversions
  • Educational tools for math and science

Key features

  • Supports multiple measurement categories
  • Cross-platform compatibility
  • Simple and type-safe API
  • Extensible unit definitions
  • Accurate decimal precision

Suitable for

  • Developers building measurement-based apps
  • Educational software creators
  • Apps needing dynamic unit switching
  • Tools requiring reliable conversions
  • Cross-platform Flutter projects

Considerations

  • Requires manual addition of custom units if needed
  • Limited to predefined unit sets
  • Not optimized for real-time high-frequency conversions
  • No built-in UI components
  • Depends on correct unit name usage

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

converter - Convert between different units of measurement

Converter

Version Build Status Coverage Status License

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 - decimetre
  • cm - centimetre
  • mm - millimetre
  • µm - micrometre
  • nm - nanometre
  • dam - decametre
  • hm - hectometre
  • km - kilometre
  • Mm - megametre
  • Gm - gigametre
  • Å - ångström
  • in - inch
  • ft - foot
  • yd - yard
  • mi - mile
  • nmi - nautical mile
Mass
  • kg - kilogram (SI)
  • hg - hectogram
  • dag - decagram
  • g - gram
  • dg - decigram
  • cg - centigram
  • mg - milligram
  • µg - microgram
  • ng - nanogram
  • Mg - megagram
  • Gg - gigagram
  • oz - ounce
  • lb - pound
  • t - tonne or metric ton
  • long-ton | ton - long ton or imperial ton
  • short-ton - short ton
Time
  • s - second (SI)
  • ds - decisecond
  • cs - centisecond
  • ms - millisecond
  • µs - microsecond
  • ns - nanosecond
  • das - decasecond
  • hs - hectosecond
  • ks - kilosecond
  • Ms - megasecond
  • Gs - gigasecond
  • min - minute
  • h - hour
  • d - day
  • wk - week
  • fn - fortnight
  • mo - month
  • y - year
  • dec - decade
  • c - century
ElectricCurrent
  • A - ampere (SI)
  • mA - milliampere
  • kA - kiloampere
  • statA - statampere
  • abA | Bi - abampere or biot
Temperature
  • K - kelvin (SI)
  • C - degree Celsius
  • F - degree Fahrenheit
  • R - degree Rankine
Acceleration
  • m/s2 - metre per second squared (SI)
  • cm/s2 | gal - centimetre per second squared or galileo
  • ft/s2 - foot per second squared
  • g - standard gravity
Area
  • m2 - square metre (SI)
  • dm2 - square decimetre
  • cm2 - square centimetre
  • mm2 - square millimetre
  • µm2 - square micrometre
  • dam2 - square decametre
  • hm2 | ha - square hectometre or hectare
  • km2 - square kilometre
  • Mm2 - square megametre
  • in2 - square inch
  • ft2 - square foot
  • mi2 - square mile
  • ac - acre
ElectricCharge
  • C - coulomb (SI)
  • mC - millicoulomb
  • µC - microcoulomb
  • nC - nanocoulomb
  • Ah - ampere hour
  • mAh - milliampere hour
  • statC | Fr - statcoulomb or franklin
  • abC - abcoulomb
Force
  • N - newton (SI)
  • dyn - dyne
  • gf - gram-force
  • kgf - kilogram-force
  • lbf - pound-force
  • pdl - poundal
Frequency
  • Hz - hertz (SI)
  • kHz - kilohertz
  • MHz - megahertz
  • GHz - gigahertz
  • THz - terahertz
  • rad/s - radian per second
  • deg/s - degree per second
  • rpm - revolutions per minute
PlaneAngle
  • rad - radian (SI)
  • mrad - milliradian
  • deg - degree
  • arcmin - arcminute
  • arcsec - arcsecond
  • grad - gradian
SolidAngle
  • sr - steradian (SI)
  • deg2 - square degree
Speed
  • m/s - metre per second (SI)
  • km/h - kilometre per hour
  • ft/s - foot per second
  • mi/h - mile per hour
  • kn - knot
Volume
  • m3 | kl - cubic metre or kilolitre (SI)
  • dm3 | l - cubic decimetre or litre
  • cm3 | ml - cubic centimetre or millilitre
  • mm3 | µl - cubic millimetre or microlitre
  • dam3 | Ml - cubic decametre or megalitre
  • hm3 | Gl - cubic hectometre or gigalitre
  • km3 | Tl - cubic kilometre or teralitre
  • in3 - cubic inch
  • ft3 - cubic foot
  • mi3 - cubic mile
  • gal - gallon
  • qt - quart
  • pt - pint
  • fl-oz - fluid ounce
  • tbsp - tablespoon
  • tsp - teaspoon

Syntax

See documentation for more

License

MIT

Categories

Dependencies

Dependency list 2 items

Source repository

Projects using this package

No data available yet.