units 0.0.7

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 64

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

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 packages get

Alternatively, your editor might support pub get or flutter packages 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';
  
Version Uploaded Documentation Archive
0.0.7 Feb 10, 2018 Go to the documentation of units 0.0.7 Download units 0.0.7 archive
0.0.6 Oct 15, 2017 Go to the documentation of units 0.0.6 Download units 0.0.6 archive
0.0.5 Oct 14, 2017 Go to the documentation of units 0.0.5 Download units 0.0.5 archive
0.0.4 Oct 13, 2017 Go to the documentation of units 0.0.4 Download units 0.0.4 archive
0.0.3 Oct 13, 2017 Go to the documentation of units 0.0.3 Download units 0.0.3 archive
0.0.2 Oct 13, 2017 Go to the documentation of units 0.0.2 Download units 0.0.2 archive
0.0.1 Oct 12, 2017 Go to the documentation of units 0.0.1 Download units 0.0.1 archive

Analysis

We analyzed this package on Jun 19, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.63.0
  • pana: 0.11.3

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
32 / 100
Health:
Code health derived from static analysis. [more]
95 / 100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100 / 100
Overall score:
Weighted score of the above. [more]
64
Learn more about scoring.

Platforms

Detected platforms: Flutter, web, other

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

Suggestions

  • The description is too short.

    Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 7 hints.

    Run dartfmt to format lib/src/angle.dart.

    Run dartfmt to format lib/src/length.dart.

    Similar analysis of the following files failed:

    • lib/src/speed.dart (hint)
    • lib/src/temperature.dart (hint)
    • lib/units.dart (hint)

Dependencies

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