🚀 Usage

Once you have installed number2words, you can start converting numbers into words with just a single function call.

🔹 Basic Conversion

Convert a number into words using the convert method:

import 'package:number2words/number2words.dart';

void main() {
  String result = Number2Words.convert(123);
  print(result); // Output: "One Hundred Twenty-Three"
}

🔹 Converting Decimal Numbers

Easily convert decimal numbers with proper formatting:

String result = Number2Words.convert(1234.56);
print(result); // Output: "One Thousand Two Hundred Thirty-Four and Fifty-Six Hundredths"

🔹 Customizing Output

Change Letter Case

You can specify different word cases (e.g., lowercase, uppercase, title case):

String result = Number2Words.convert(789, wordCase: WordCaseEnum.titleCase);
print(result); // Output: "Seven Hundred Eighty-Nine"

Language Support (If applicable)

If your package supports multiple languages, include an option to specify the language:

String result = Number2Words.convert(2024, language: Number2WordsLanguage.spanish);
print(result); // Output: "Dos Mil Veinticuatro"

🔹 More Examples

Number

Output

5

"Five"

42

"Forty-Two"

1050

"One Thousand Fifty"

999999

"Nine Hundred Ninety-Nine Thousand Nine Hundred Ninety-Nine"

1200000

"One Million Two Hundred Thousand"

Now that you know how to use number2words, explore the Customization Options section to fine-tune the output.

Updated on