massive 1.0.0 massive: ^1.0.0 copied to clipboard
Massive ==> Visionary Software Solutions Mass me_sure_meant API.
import 'package:massive/massive.dart';
import 'package:me_sure_meant/me_sure_meant.dart';
void main() {
final ounces = 16.ounces();
areEqual(1.pounds(), ounces);
/// Supporting esoteric imperial units
/// I've actually witnessed people describing their weight in stones in
/// the UK, so this one feels more worthy of extension than [Hands]
final stones = 12.stones();
areEqual(stones, (14 * 12).pounds());
/// The Imperial Ton is the "Long Ton."
/// https://en.wikipedia.org/wiki/Long_ton
/// In principle it's not difficult to add the "Short Ton" or the "Metric Ton"
/// but that can be done by extension libraries that build on this one
/// (it's easy). After doing volumes I'm tapping out on US/UK differences.
final tons = 1.tons();
areEqual(tons, 2240.pounds());
/// Common conversions for weight checking around the world
final kilograms = 89.99998368592.kilograms();
198.416.pounds().toUnit(Gram.kilogram);
areEqual(kilograms, 198.416.pounds());
final picograms = kilograms.toUnit(Gram.picogram);
/// the library supports comparisons using compareTo and natural operators
assert(1.grams() < picograms);
assert(100.kilograms().compareTo(picograms) > 0);
final mess =
(20.pounds() + 32.stones() + Grams(crude(8), Gram.megagram) - 4.tons())
.toUnit(Gram.kilogram);
print(mess);
areEqual(mess, 4148.093593959998.kilograms());
}
void massDemo() {
/// At this point, it's mostly showing the same stuff for different
/// supported units.
final ounces = 16.ounces();
areEqual(1.pounds(), ounces);
/// Supporting esoteric imperial units
/// I've actually witnessed people describing their weight in stones in
/// the UK, so this one feels more worthy of extension than [Hands]
final stones = 12.stones();
areEqual(stones, (14 * 12).pounds());
/// The Imperial Ton is the "Long Ton."
/// https://en.wikipedia.org/wiki/Long_ton
/// In principle it's not difficult to add the "Short Ton" or the "Metric Ton"
/// but that can be done by extension libraries that build on this one
/// (it's easy). After doing volumes I'm tapping out on US/UK differences.
final tons = 1.tons();
areEqual(tons, 2240.pounds());
/// Common conversions for weight checking around the world
final kilograms = 89.99998368592.kilograms();
198.416.pounds().toUnit(Gram.kilogram);
areEqual(kilograms, 198.416.pounds());
final picograms = kilograms.toUnit(Gram.picogram);
/// the library supports comparisons using compareTo and natural operators
assert(1.grams() < picograms);
assert(100.kilograms().compareTo(picograms) > 0);
final mess =
(20.pounds() + 32.stones() + Grams(crude(8), Gram.megagram) - 4.tons())
.toUnit(Gram.kilogram);
print(mess);
areEqual(mess, 4148.093593959998.kilograms());
}
void areEqual(final one, final two) {
assert(one == two);
}