-
Notifications
You must be signed in to change notification settings - Fork 1
Home
If you are migrating from version 2.x to 3.x, a lot has changed! See the guide for tips.
A type-safe Dart library for unit conversion. Create and pass around abstractions of units and measurements to make your code cleaner and easier to read!
var measurement = 4.centi.meters;
print(measurement.butAs(inches));
// 1.574803 in
We designed fling_units to simplify working with any measurement or unit within a code base by abstracting them to basic types. Units can be "called" to create measurements, and measurements can be "interpreted" into any valid unit in the same dimension, all in a type-safe way. This means you will never pass around a measurement of the wrong type or unit again without seeing red squiggles in your IDE.
Fling Units is designed to be self-explanatory, so you can dive right in. Once you're comfortable, have a look at the cookbook for more ideas and to see the full power of the library. Also, be sure to check the lexicon for explanations of the terminology we use if you're confused about the concepts.
-
Simplicity: Casual users must be able to pick up the basic features. We prefer idiomatic approaches since users will already have experience with them. The library will not offer confusing or difficult options.
-
Safety: We will protect against invalid or incorrect usage. We favor compile-time checks over runtime checks. If something is possible with the library, it must be valid in the real world.
-
Correctness: Conversions must be accurate. The limiting factor in accuracy is the measurement itself, not the library. Bug fixes take top priority. Full test coverage is required.
-
Minimalism: We will not depend on larger libraries or other difficult dependencies. Including the library into a project must be easy and must not require any configuration or complicated setup.
-
Performance: While we will not try to make the library slower than it needs to be, we will not make small performance enhancements at the cost of other design goals.
-
Memory: We will not reduce memory footprint at the cost of one of the other design goals, but we will keep the library as small and unobtrusive as possible.
Let us know how we can improve fling_units by creating an issue!