number2words 0.0.5 copy "number2words: ^0.0.5" to clipboard
number2words: ^0.0.5 copied to clipboard

A new Flutter package for converting numbers to words. This package suits best for multilingual applications and is inspired by the PHP package

example/lib/main.dart

import 'package:flutter/material.dart';

/// Import the package
import 'package:number2words/number2words.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;

  void _incrementCounter() {
    setState(() {
      _counter++;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            const Text(
              'You have pushed the button this many times:',
            ),

            /// Example of usage
            Text(Number2Words.convert(
              123444.03,
              language: Number2WordsLanguage.english,
              wordCase: WordCaseEnum.titleCase,
            )),

            ///  One Lakh Twenty Three Thousand Four Hundred Forty Four Rupees And Three Paisa Only

            /// Example of usage
            Text(Number2Words.convert(123444.03,
                language: Number2WordsLanguage.nepali,
                wordCase: WordCaseEnum.titleCase,
                languageNamingSystem: LanguageNamingSystem.native)),

            ///  एक लाख तेइस हजार चार सय चवालिस रुपैया, तीन पैसा

            /// Example of usage
            Text(Number2Words.convert(
              123444.03,
              language: Number2WordsLanguage.nepali,
              wordCase: WordCaseEnum.titleCase,
              languageNamingSystem: LanguageNamingSystem.semiNative,
            )),

            /// One Lakh Twenty-three Thousand Four Hundred Forty-four Rupees And Three Paisa

            Text(Number2Words.convert(
              11123444.03,
              language: Number2WordsLanguage.nepali,
              wordCase: WordCaseEnum.titleCase,
              languageNamingSystem: LanguageNamingSystem.international,
            )),

            /// Eleven Million One Hundred Twenty-three Thousand Four Hundred Forty-four Rupees And Three Paisa

            Text(
              '$_counter',
              style: Theme.of(context).textTheme.headlineMedium,
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: const Icon(Icons.add),
      ),
    );
  }
}
3
likes
140
points
258
downloads

Publisher

verified publisherrabinacharya.info.np

Weekly Downloads

A new Flutter package for converting numbers to words. This package suits best for multilingual applications and is inspired by the PHP package

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on number2words