# Units

A starting point for measurement units in Dart.

Included right now:

• `Speed`

• Meter per second `m/s`
• Kilometer per hour `km/h`
• Mile per hour `mi/h`
• Knot `kn`
• `Length`

• Meter `m`
• Kilometer `km`
• Mile `mi`
• `Angle`

• Degree `°`
• Radian `rad`
• Gradian `grad`

Supports negative angles, not restricted to 360 degrees or 2PI radians

• `Temperature`

• Celsius `°C`
• Fahrenheit `°F`
• Kelvin `K`
• Rankine `°R`
• Romer `°Rø`

## Usage #

A simple usage example:

``````    import 'package:units/units.dart';

main() {
var speed = new Speed.fromKilometerPerHour(value: 360.0);
print('360 km/h are \${speed.inMeterPerSecond} m/s');
print('360 km/h are \${speed.inMeterPerSecond} mi/h');
}
``````

Note: All numbers are forced to a max representation with exactly 6 significant digits.

For example: `12345678910.12345678` will turn into: `12345678910.123457`

# Changelog #

## 0.0.1 #

• Initial version

Included right now:

• `Speed`
• `Length`

## 0.0.2 #

Minor improvements to Speed and Length, also added some tests

Now, all numbers are forced to a max representation of exactly 6 significant digits For example: 12345678910.12345678 will turn into: 12345678910.123457

## 0.0.3 #

Minor update, add new tests

## 0.0.4 #

Added `Angle` unit Supports negative angles, not restricted to 360 degrees or 2PI radians

## 0.0.5 #

Added `Temperature` unit ... works with: Celsius, Fahrenheit, Kelvin, Rankine and Romer

## 0.0.6 #

Add `Gradian` to `Angle`

## 0.0.7 #

Minor update to remove the upper bound sdk limit constraint

example/units_example.dart

``````import 'package:units/units.dart';

main() {
var speed = new Speed.fromKilometerPerHour(value: 360.0);
print('360 km/h are \${speed.inMeterPerSecond} m/s');
print('360 km/h are \${speed.inMeterPerSecond} mi/h');
}
``````

## Use this package as a library

### 1. Depend on it

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

``````
dependencies:
units: ^0.0.7

``````

### 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:units/units.dart';
``````
 Popularity: Describes how popular the package is relative to other packages. [more] 65 Health: Code health derived from static analysis. [more] 28 Maintenance: Reflects how tidy and up-to-date the package is. [more] 0 Overall: Weighted score of the above. [more] 41

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

• Dart: 2.7.0
• pana: 0.13.4

#### Health issues and suggestions

Fix `lib/src/angle.dart`. (-69.14 points)

Analysis of `lib/src/angle.dart` failed with 4 errors, 5 hints, including:

line 10 col 42: Const variables must be initialized with a constant value.

line 10 col 42: Undefined name 'PI'.

line 13 col 50: Const variables must be initialized with a constant value.

line 13 col 50: Undefined name 'PI'.

line 1 col 8: Unused import: 'dart:math'.

Document public APIs. (-1 points)

35 out of 35 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Fix `lib/src/temperature.dart`. (-2.96 points)

Analysis of `lib/src/temperature.dart` reported 6 hints, including:

line 25 col 43: Use `=` to separate a named parameter from its default value.

line 26 col 46: Use `=` to separate a named parameter from its default value.

line 27 col 42: Use `=` to separate a named parameter from its default value.

line 28 col 43: Use `=` to separate a named parameter from its default value.

line 29 col 41: Use `=` to separate a named parameter from its default value.

Fix `lib/src/speed.dart`. (-2.48 points)

Analysis of `lib/src/speed.dart` reported 5 hints:

line 19 col 50: Use `=` to separate a named parameter from its default value.

line 20 col 52: Use `=` to separate a named parameter from its default value.

line 21 col 46: Use `=` to separate a named parameter from its default value.

line 22 col 39: Use `=` to separate a named parameter from its default value.

line 31 col 5: Prefer using /// for doc comments.

Fix `lib/src/length.dart`. (-1.99 points)

Analysis of `lib/src/length.dart` reported 4 hints:

line 16 col 37: Use `=` to separate a named parameter from its default value.

line 17 col 41: Use `=` to separate a named parameter from its default value.

line 18 col 36: Use `=` to separate a named parameter from its default value.

line 25 col 5: Prefer using /// for doc comments.

Format `lib/units.dart`.

Run `dartfmt` to format `lib/units.dart`.

#### Maintenance suggestions

Package is getting outdated. (-96.16 points)

The package was last published 102 weeks ago.

The package description is too short. (-13 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.

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of `0.0.*`, it might mean that the author is still experimenting with the general direction of the API.

#### Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.20.1 <3.0.0
Dev dependencies
test ^0.12.0