# quantity #

Facilitates working with physical quantities such as angles, lengths, masses and temperatures.

In science and engineering it is critical to use units along with numerical values. For example, 5 meters per second is decidedly not the same speed as 5 feet per minute. Calculations must include units, implicitly or explicitly, to be correct and useful. This package provides classes for modeling quantities of specific types and their associated units as well as their use in calculations.

The International System of Units (often called 'SI' from its abbreviation in French) defines the quantity types, associated units and constants used by scientists and engineers around the world. This package models the SI base and derived quantities in its `quantity_si` library.

There are also many historical units, of course, that were around well before the SI came into existence. These can be found in the `quantity_ext` library.

The `number` library adds support for quantities having values of arbitrary precision and the `quantity_range` library adds special support for handling value ranges.

Together, these libraries give you the tools to maintain units discipline in your code and make Dart a more attractive option for many science and engineering applications by eliminating common mistakes and offering improved readability.

## Quick start #

``````// Import the core library.
import 'package:quantity/quantity_si.dart';

// Construct an Angle in radians.
var ang = new Angle(rad: 1.1);

// Construct an Angle in degrees.
var ang2 = new Angle(deg: 270);

// Find the difference.
var diff = ang2 - ang;

// Display the result in degrees.
print(diff.valueInUnits(Angle.degrees);
``````

## Key Features #

• Typed quantities (such as `Length`, `Mass` and `Temperature`) that are easy to construct and use in calculations.
• Encourages use of standard units by isolating non-standard units in an extension library.
• Support for relative standard uncertainty in quantity values and calculations.
• Allows use of arbitrary precision values (as well as complex and imaginary values).
• Integration with Dart's existing `Duration` and `DateTime` classes.
• Extensive set of quantity types and standard and non-standard units.
• Support for untyped quantities having unusual dimensions with the `MiscQuantity` class.
• Models quantity ranges, including special support for angle ranges and time spans.
• Includes a mutable quantity with streams.
• Metric prefixes for any unit.

### 0.3.0 #

• Relaxed version constraint on package `intl`.

### 0.2.0+1 #

• Dart 2 support.
• Stricter typing.
• Addressed many (but not all) analyzer items.

### 0.1.5 #

• Upgraded dependencies: `intl 0.14` and `quiver 0.23`

### 0.1.4 #

• Added `isScalar` and `isScalarSI` to `Dimensions` and `Quantity`.
• Extended use of type hints in dimensions for more efficient and accurate type determination during operations.
• Generalized special handling of scalar quantities.

### 0.1.3+1 #

• Fixed `CHANGELOG.md` formatting.

### 0.1.3 #

• Added `operator ==` and `hashCode` to quantity range classes.
• Added `toTypedQuantity` to `MiscQuantity`.
• Changed `googol` constant to arbitrary precision.
• Renamed private `_dimensions` constructor to `_internal` in quantities.

### 0.1.2 #

• `Precise` `isInteger` and `_limitPrecision` fixes.
• `hashCode` testing for quantity objects (esp. `Scalar`)

### 0.1.1 #

• `Temperature`, `TemperatureInterval` tests, tweaks, bug fixes.

### 0.1.0 #

• Initial version.

## Use this package as a library

### 1. Depend on it

``````
dependencies:
quantity: ^0.3.0

``````

### 2. Install it

You can install packages from the command line:

with pub:

``````
\$ pub get

``````

with Flutter:

``````
\$ flutter pub get

``````

Alternatively, your editor might support `pub get` or `flutter pub get`. Check the docs for your editor to learn more.

### 3. Import it

Now in your Dart code, you can use:

``````
import 'package:quantity/quantity.dart';
``````
 Popularity: Describes how popular the package is relative to other packages. [more] 62 Health: Code health derived from static analysis. [more] 75 Maintenance: Reflects how tidy and up-to-date the package is. [more] 75 Overall: Weighted score of the above. [more] 68

We analyzed this package on Apr 3, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

• Dart: 2.7.1
• pana: 0.13.6

#### Health suggestions

Fix `lib/quantity_si.dart`. (-25 points)

Analysis of `lib/quantity_si.dart` reported 81 hints, including:

line 103 col 18: Unnecessary new keyword.

line 111 col 60: Unnecessary new keyword.

line 113 col 7: Unnecessary new keyword.

line 115 col 7: Unnecessary new keyword.

line 117 col 7: Unnecessary new keyword.

Fix `lib/src/ext/scalar_ext.dart`. (-24.47 points)

Analysis of `lib/src/ext/scalar_ext.dart` reported 56 hints, including:

line 10 col 35: Unnecessary new keyword.

line 13 col 34: Unnecessary new keyword.

line 16 col 32: Unnecessary new keyword.

line 19 col 33: Unnecessary new keyword.

line 22 col 32: Unnecessary new keyword.

Fix `lib/src/number/complex.dart`. (-24.10 points)

Analysis of `lib/src/number/complex.dart` reported 55 hints, including:

line 16 col 16: Unnecessary new keyword.

line 17 col 21: Unnecessary new keyword.

line 17 col 44: Unnecessary new keyword.

line 20 col 52: Unnecessary new keyword.

line 22 col 15: Unnecessary new keyword.

Fix additional 135 files with analysis or formatting issues. (-516.05 points)

Additional issues in the following files:

• `lib/src/number/imaginary.dart` (51 hints)
• `lib/src/number/real.dart` (50 hints)
• `lib/src/number/precise.dart` (49 hints)
• `lib/src/ext/length_ext.dart` (46 hints)
• `lib/domain/thermodynamic.dart` (42 hints)
• `lib/src/ext/time_instant_ext.dart` (41 hints)
• `lib/src/ext/mass_ext.dart` (38 hints)
• `lib/src/ext/volume_ext.dart` (29 hints)
• `lib/range/angle_range.dart` (28 hints)
• `lib/src/number/integer.dart` (27 hints)
• `lib/src/ext/energy_ext.dart` (23 hints)
• `lib/src/ext/angle_ext.dart` (18 hints)
• `lib/src/ext/mutable/mutable_quantity.dart` (17 hints)
• `lib/src/si/dimensions.dart` (17 hints)
• `lib/domain/astronomical.dart` (14 hints)
• `lib/src/si/quantity.dart` (14 hints)
• `lib/src/ext/power_ext.dart` (13 hints)
• `lib/src/ext/speed_ext.dart` (13 hints)
• `lib/src/number/double.dart` (13 hints)
• `lib/src/si/types/angle.dart` (13 hints)
• `lib/src/si/types/time_instant.dart` (13 hints)
• `lib/domain/electromagnetic.dart` (12 hints)
• `lib/src/ext/area_ext.dart` (12 hints)
• `lib/src/ext/pressure_ext.dart` (12 hints)
• `lib/src/si/types/information.dart` (12 hints)
• `lib/src/ext/time_ext.dart` (11 hints)
• `lib/src/si/types/level.dart` (9 hints)
• `lib/src/si/types/mass.dart` (9 hints)
• `lib/src/si/types/temperature.dart` (9 hints)
• `lib/src/si/types/temperature_interval.dart` (9 hints)
• `lib/range/time_period.dart` (8 hints)
• `lib/src/si/types/energy.dart` (8 hints)
• `lib/src/si/types/information_rate.dart` (8 hints)
• `lib/src/si/types/time.dart` (8 hints)
• `lib/src/ext/charge_ext.dart` (7 hints)
• `lib/src/ext/solid_angle_ext.dart` (7 hints)
• `lib/src/si/types/area.dart` (7 hints)
• `lib/src/si/types/length.dart` (7 hints)
• `lib/domain/universal.dart` (6 hints)
• `lib/src/ext/angular_momentum_ext.dart` (6 hints)
• `lib/src/ext/force_ext.dart` (6 hints)
• `lib/src/ext/temperature_ext.dart` (6 hints)
• `lib/src/number/number.dart` (6 hints)
• `lib/src/ext/entropy_ext.dart` (5 hints)
• `lib/src/si/types/absorbed_dose.dart` (5 hints)
• `lib/src/si/types/absorbed_dose_rate.dart` (5 hints)
• `lib/src/si/types/activity.dart` (5 hints)
• `lib/src/si/types/angular_acceleration.dart` (5 hints)
• `lib/src/si/types/angular_speed.dart` (5 hints)
• `lib/src/si/types/currency.dart` (5 hints)
• `lib/src/si/types/dose_equivalent.dart` (5 hints)
• `lib/src/si/types/exposure.dart` (5 hints)
• `lib/src/si/types/permeability.dart` (5 hints)
• `lib/src/si/types/pressure.dart` (5 hints)
• `lib/src/si/types/scalar.dart` (5 hints)
• `lib/src/si/types/speed.dart` (5 hints)
• `lib/src/si/types/volume.dart` (5 hints)
• `lib/number.dart` (4 hints)
• `lib/src/ext/acceleration_ext.dart` (4 hints)
• `lib/src/ext/magnetic_flux_ext.dart` (4 hints)
• `lib/src/ext/mass_density_ext.dart` (4 hints)
• `lib/src/ext/resistance_ext.dart` (4 hints)
• `lib/src/si/types/acceleration.dart` (4 hints)
• `lib/src/si/types/amount_of_substance.dart` (4 hints)
• `lib/src/si/types/angular_momentum.dart` (4 hints)
• `lib/src/si/types/capacitance.dart` (4 hints)
• `lib/src/si/types/catalytic_activity.dart` (4 hints)
• `lib/src/si/types/charge.dart` (4 hints)
• `lib/src/si/types/charge_density.dart` (4 hints)
• `lib/src/si/types/concentration.dart` (4 hints)
• `lib/src/si/types/conductance.dart` (4 hints)
• `lib/src/si/types/current.dart` (4 hints)
• `lib/src/si/types/current_density.dart` (4 hints)
• `lib/src/si/types/dynamic_viscosity.dart` (4 hints)
• `lib/src/si/types/electric_field_strength.dart` (4 hints)
• `lib/src/si/types/electric_flux_density.dart` (4 hints)
• `lib/src/si/types/electric_potential_difference.dart` (4 hints)
• `lib/src/si/types/energy_density.dart` (4 hints)
• `lib/src/si/types/energy_flux.dart` (4 hints)
• `lib/src/si/types/entropy.dart` (4 hints)
• `lib/src/si/types/force.dart` (4 hints)
• `lib/src/si/types/frequency.dart` (4 hints)
• `lib/src/si/types/heat_flux_density.dart` (4 hints)
• `lib/src/si/types/illuminance.dart` (4 hints)
• `lib/src/si/types/inductance.dart` (4 hints)
• `lib/src/si/types/kinematic_viscosity.dart` (4 hints)
• `lib/src/si/types/luminance.dart` (4 hints)
• `lib/src/si/types/luminous_flux.dart` (4 hints)
• `lib/src/si/types/luminous_intensity.dart` (4 hints)
• `lib/src/si/types/magnetic_field_strength.dart` (4 hints)
• `lib/src/si/types/magnetic_flux.dart` (4 hints)
• `lib/src/si/types/magnetic_flux_density.dart` (4 hints)
• `lib/src/si/types/mass_density.dart` (4 hints)
• `lib/src/si/types/mass_flow_rate.dart` (4 hints)
• `lib/src/si/types/mass_flux_density.dart` (4 hints)
• `lib/src/si/types/molar_energy.dart` (4 hints)
• `lib/src/si/types/molar_entropy.dart` (4 hints)
• `lib/src/si/types/permittivity.dart` (4 hints)
• `lib/src/si/types/power.dart` (4 hints)
• `lib/src/si/types/radiance.dart` (4 hints)
• `lib/src/si/types/radiant_intensity.dart` (4 hints)
• `lib/src/si/types/resistance.dart` (4 hints)
• `lib/src/si/types/solid_angle.dart` (4 hints)
• `lib/src/si/types/specific_energy.dart` (4 hints)
• `lib/src/si/types/specific_heat_capacity.dart` (4 hints)
• `lib/src/si/types/specific_volume.dart` (4 hints)
• `lib/src/si/types/spectral_irradiance.dart` (4 hints)
• `lib/src/si/types/surface_tension.dart` (4 hints)
• `lib/src/si/types/thermal_conductivity.dart` (4 hints)
• `lib/src/si/types/torque.dart` (4 hints)
• `lib/src/si/types/volume_flow_rate.dart` (4 hints)
• `lib/src/si/types/wave_number.dart` (4 hints)
• `lib/src/si/units.dart` (4 hints)
• `lib/src/ext/conductance_ext.dart` (3 hints)
• `lib/src/ext/current_ext.dart` (3 hints)
• `lib/src/ext/kinematic_viscosity_ext.dart` (3 hints)
• `lib/src/ext/magnetic_flux_density_ext.dart` (3 hints)
• `lib/range/quantity_range.dart` (2 hints)
• `lib/src/ext/capacitance_ext.dart` (2 hints)
• `lib/src/ext/electric_potential_difference_ext.dart` (2 hints)
• `lib/src/ext/illuminance_ext.dart` (2 hints)
• `lib/src/ext/permeability_ext.dart` (2 hints)
• `lib/src/ext/permittivity_ext.dart` (2 hints)
• `lib/src/ext/specific_energy_ext.dart` (2 hints)
• `lib/src/ext/volume_flow_rate_ext.dart` (2 hints)
• `lib/src/ext/angular_speed_ext.dart` (1 hint)
• `lib/src/ext/energy_flux_ext.dart` (1 hint)
• `lib/src/ext/inductance_ext.dart` (1 hint)
• `lib/src/ext/spectral_irradiance_ext.dart` (1 hint)
• `lib/src/si/exponential_units.dart` (1 hint)
• `lib/src/si/misc_quantity.dart` (1 hint)
• `lib/src/ext/amount_of_substance_ext.dart` (Run `dartfmt` to format `lib/src/ext/amount_of_substance_ext.dart`.)
• `lib/src/number/fraction.dart` (Run `dartfmt` to format `lib/src/number/fraction.dart`.)
• `lib/src/si/immutable_quantity_exception.dart` (Run `dartfmt` to format `lib/src/si/immutable_quantity_exception.dart`.)
• `lib/src/si/number_format_si.dart` (Run `dartfmt` to format `lib/src/si/number_format_si.dart`.)

#### Maintenance suggestions

The package description is too short. (-15 points)

Add more detail to the `description` field of `pubspec.yaml`. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Maintain an example. (-10 points)

Create a short demo in the `example/` directory to show how to use this package.

Common filename patterns include `main.dart`, `example.dart`, and `quantity.dart`. Packages with multiple examples should provide `example/README.md`.