unit_converter 1.1.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 74

unit_converter #


A library to easily convert between units of different system.

Show some ❤️ and star the repo to support the project

GitHub starsGitHub forksGitHub watchers

Installation #

In the dependencies: section of your pubspec.yaml, add the following line:

unit_converter: <latest_version>

Usage #

If you want to convert area units, get an instance of area converter, and call the convert method:

import 'package:unit_converter/unit_converter.dart';

main() {
  var areaConverter = getConverter(Converter.area);
  areaConverter.convert(value: 2, from: AreaUnit.acre, to: AreaUnit.squareFoot);

Get the available units:

  var avilableUnits = areaConverter.units();

See units method for more details.

Each unit have a name(British spelling) and an americanName(American spelling) property. For units that have the same americanName as name, the americanName is null. So, it is always good to check for the availability of americanName before displaying it.

  for(var unit in avilableUnits) {
    if(unit.americanName != null) {
    } else {

Donations #

This project needs you! If you would like to support the creator of this project or the continuous development and maintenance of this project, feel free to donate. Your donation is highly appreciated. Thank you!


  • Donate $5: Thank's for creating this project, here's a tea (or some juice) for you!
  • Donate $10: Wow, I am amazed. Let me take you to the movies!
  • Donate $15: I really appreciate your work, let's grab some lunch!
  • Donate $25: That's some awesome stuff you did right there, dinner is on me!
  • Donate $50: I really really want to support this project, great job!
  • Donate $100: You are the man! This project saved me hours (if not days) of struggle and hard work, simply awesome!
  • Donate $2799: Go buddy, buy Macbook Pro for yourself!

Of course, you can also choose what you want to donate, all donations are awesome!

Features and bugs #

Please file feature requests and bugs at the issue tracker.

How to Contribute #

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

1.0.0 #

  • Fully working version. Various types of converter added.

1.0.0+1 #

  • Proper commenting on public APIS.

1.1.0 #

Breaking Change: New method getConverter added to get an instance of UnitConverter. Previously it was done by instantiating UnitConverter directly. We have made the UnitConverter class private to the library. So, use getConverter passing the type of Converter you need.

  • Code cleanup.
  • Better API documentation.


import 'package:unit_converter/unit_converter.dart';

main() {
  var areaConverter = getConverter(Converter.area);
    value: 2,
    from: AreaUnit.acre,
    to: AreaUnit.squareFoot,

Use this package as a library

1. Depend on it

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

  unit_converter: ^1.1.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:unit_converter/unit_converter.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 Jan 19, 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

Document public APIs. (-0.75 points)

5715 out of 5763 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/constant/others/misc.dart. (-1 points)

Analysis of lib/src/constant/others/misc.dart reported 2 hints:

line 6 col 25: Avoid const keyword.

line 30 col 24: Avoid const keyword.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.2.2 <3.0.0
Dev dependencies
pedantic ^1.0.0
test ^1.0.0