pump_up_the_volume 1.0.0 copy "pump_up_the_volume: ^1.0.0" to clipboard
pump_up_the_volume: ^1.0.0 copied to clipboard

Pump Up The Volume ==> Visionary Software Solutions Volume me_sure_meant API.

example/pump_up_the_volume_example.dart

import 'package:pump_up_the_volume/pump_up_the_volume.dart';
import 'package:pump_up_the_volume/src/volume/liquid/imperial/extensions.dart';
import 'package:pump_up_the_volume/src/volume/liquid/us_customary/extensions.dart';

void main() {
  volumeDemo();
}

void volumeDemo() {
  /// Liquid volumes are complicated, as there are a lot of units!
  final litres = 5.litres();

  /// basic math works
  final added = (litres + 250.millilitres()) - 2.5.litres();
  assert(2.75.litres() == added);

  /// The Big Win is that a variety of obnoxious units are implemented across
  /// both US Customary and Imperial systems, so defining recipe ingredients
  /// is a snap
  final americanMilk = USVolumes(4).gallons() +
      USVolumes(32).fluidOunces() +
      USVolumes(2).pints() -
      USVolumes(10).quarts() +
      USVolumes(6).shots() -
      USVolumes(4).cups();
  print("That's a lot to chug! $americanMilk");
  final imperialMilk = ImperialLiquidVolumes(4).gallons() +
      ImperialLiquidVolumes(10).pints() -
      ImperialLiquidVolumes(5).quarts() -
      ImperialLiquidVolumes(28).fluidOunces();
  print("A right proper drink $imperialMilk");

  /// You'll notice I had to use Extension Overrides, a rather under-documented
  /// Dart feature created by the lack of namespaces.
  /// In normal usage, I expect EITHER one OR the other would be imported.
  /// The cool thing is...watch this
  final revolution = imperialMilk - americanMilk;

  /// the tedious little differences between US fl oz/pints/quarts and
  /// Imperial are taken care of
  print("viva! $revolution");

  /// For more explicit usage between the two, you can use hackily
  /// re-named types
  final shortChanged = USPints.fromNum(2);
  final biggerDrink = ImperialPints.fromNum(2);
  assert(biggerDrink > shortChanged);

  /// all this namespace abuse is making me feel like some...
  final finale = 10.shots();
  print("Jäger! Jäger! Jäger! $finale");
}
1
likes
150
points
26
downloads

Publisher

verified publishervisionary.software

Weekly Downloads

Pump Up The Volume ==> Visionary Software Solutions Volume me_sure_meant API.

Repository

Documentation

API reference

License

GPL-3.0 (license)

Dependencies

me_sure_meant

More

Packages that depend on pump_up_the_volume