quantify 0.2.0 copy "quantify: ^0.2.0" to clipboard
quantify: ^0.2.0 copied to clipboard

A type-safe units of measurement library for Dart, providing elegant syntax for unit conversions with good precision, optimal performance, and configurable output formatting.

example/README.md

Quantify Package - CLI Example #

This directory contains a command-line interface (CLI) example demonstrating the features of the quantify package.

Features Demonstrated #

The quantify_cli_example.dart script showcases:

  • Creating Quantities:
    • Using intuitive num extensions (e.g., 1500.m, 2.5.km).
  • Unit Conversions:
    • Retrieving numerical values in different units (e.g., pathA.inKm).
    • Converting Quantity objects to different units (e.g., pathA.convertTo(LengthUnit.kilometer)).
  • String Formatting (toString()):
    • Default formatting.
    • Specifying a targetUnit for conversion before formatting.
    • Controlling the number of fractionDigits.
    • Using a unitSymbolSeparator.
    • Locale-specific number formatting using the locale parameter (requires the intl package).
    • Using a custom intl.NumberFormat instance for advanced control over number display.
  • Arithmetic Operations:
    • Adding (+) and subtracting (-) quantities (automatic unit conversion for the right-hand operand).
    • Multiplying (*) and dividing (/) quantities by a scalar.
    • Specific arithmetic for Temperature (e.g., difference).
  • Comparisons:
    • Using compareTo() for magnitude comparison.
    • Using == to check for equality in both value and unit.
    • Sorting lists of Quantity objects.
  • Usage of various implemented quantity types:
    • Length
    • Time
    • Temperature
    • Pressure

How to Run #

  1. Navigate to the root directory of the quantify package.

  2. Ensure dependencies are fetched:

    dart pub get
    
  3. Run the example script from the example directory:

    dart run example/quantify_cli_example.dart
    

    Alternatively, if you are already in the example directory:

    dart run quantify_cli_example.dart
    

Dependencies #

This example depends on:

  • The main quantify package (referenced via path: ../ in its pubspec.yaml).
  • The intl package for locale-specific number formatting features.
10
likes
0
points
68
downloads

Publisher

verified publisherphilippgerber.li

Weekly Downloads

A type-safe units of measurement library for Dart, providing elegant syntax for unit conversions with good precision, optimal performance, and configurable output formatting.

Repository (GitHub)
View/report issues

Topics

#units #measurement #conversion #physics #utility

License

unknown (license)

Dependencies

intl, meta

More

Packages that depend on quantify