to_words 0.1.0 copy "to_words: ^0.1.0" to clipboard
to_words: ^0.1.0 copied to clipboard

A Dart library to convert numbers to words. A port of the to-words JavaScript library.

to_words (Dart) #

A Dart port of the popular to-words JavaScript library for converting numbers to words.

Features #

  • Convert numbers (integers and decimals) to words and currency.
  • Extensible design to support multiple locales.
  • Full support for currency, decimals, and negative numbers.
  • Currently supports US English (en-US).

Installation #

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

dependencies:
  to_words: ^0.1.0

Then run dart pub get or flutter pub get.

Usage #

Import the library and use the toWords function.

import 'package:to_words/to_words.dart';

void main() {
  // Simple number conversion
  print(toWords(123)); 
  // > One Hundred Twenty Three

  // Currency conversion
  print(toWords(1234.56,
    options: const ToWordsOptions(
      converterOptions: ConverterOptions(
        currency: true,
      ),
    ),
  ));
  // > One Thousand Two Hundred Thirty Four Dollars And Fifty Six Cents
}
7
likes
0
points
30
downloads

Publisher

unverified uploader

Weekly Downloads

A Dart library to convert numbers to words. A port of the to-words JavaScript library.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

collection

More

Packages that depend on to_words