units 0.0.6

Units Pub Travis status Coverage Status

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

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');
}

1. Depend on it

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

dependencies:
  units: "^0.0.6"

2. Install it

You can install packages from the command line:

$ pub get

Alternatively, your editor might support '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';

Platforms

About

A starting point for measurement units in Dart.

Author

Email yeradis@gmail.com Yeradis P. Barbosa Marrero

Homepage

github.com/yeradis/units.dart

Documentation

www.dartdocs.org/documentation/units/0.0.6/

Uploader

yeradis@gmail.com

Published

Oct 15, 2017

Share