quantity 0.2.0+1

  • Readme
  • Changelog
  • Installing
  • 68

quantity #

Facilitates working with physical quantities.

This is a work in progress; this package's API may change significantly.
Some parts are currently unfinished, untested and/or undocumented. Use at your own risk.

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

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).
  • Provides access to the latest official constant values published by NIST.
  • 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.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

Add this to your package's pubspec.yaml file:

  quantity: ^0.2.0+1

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';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Oct 11, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.5.1
  • pana: 0.12.21


Detected platforms: Flutter, web, other

No platform restriction found in primary library package:quantity/quantity.dart.

Health suggestions

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

Analysis of lib/src/number/complex.dart reported 4 hints:

line 104 col 7: DO use curly braces for all flow control structures.

line 117 col 7: DO use curly braces for all flow control structures.

line 120 col 7: DO use curly braces for all flow control structures.

line 123 col 7: DO use curly braces for all flow control structures.

Fix lib/src/number/imaginary.dart. (-1.99 points)

Analysis of lib/src/number/imaginary.dart reported 4 hints:

line 71 col 7: DO use curly braces for all flow control structures.

line 84 col 7: DO use curly braces for all flow control structures.

line 105 col 7: DO use curly braces for all flow control structures.

line 107 col 7: DO use curly braces for all flow control structures.

Fix lib/src/number/real.dart. (-1.49 points)

Analysis of lib/src/number/real.dart reported 3 hints:

line 57 col 7: DO use curly braces for all flow control structures.

line 72 col 7: DO use curly braces for all flow control structures.

line 131 col 20: The value of the local variable 'aOverc2d2' isn't used.

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

Additional issues in the following files:

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

Maintenance issues and suggestions

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (intl).

Package is getting outdated. (-18.08 points)

The package was last published 61 weeks ago.

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.

For more information see the pub package layout conventions.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.24.3 <3.0.0
dart2_constant ^1.0.1+dart1 1.0.2+dart2
intl ^0.15.0 0.15.8 0.16.0
logging ^0.11.3 0.11.3+2
Transitive dependencies
path 1.6.4
Dev dependencies
test >=0.12.30