digit_to_words_bd

A Dart package to convert numeric digits into their corresponding words representation.

Features

  • Converts numeric digits into words.
  • Handles conversion for integers and decimal numbers.
  • Supports conversion for numbers up to the Arab scale.

Getting Started

To use this package, add digit_to_words_bd as a dependency in your pubspec.yaml file.

dependencies:
  digit_to_words_bd: ^1.0.10

platforms:
  ios: '9.0'
  android: ^16.0.0

Then, import the package into your Dart code:

import 'package:digit_to_words_bd/digit_to_words_bd.dart';

Now you can use the digit_to_words_bd function to convert numeric digits into words.


import 'package:flutter/material.dart';
import 'dart:async';
import 'package:your_package/digit_to_words.dart'; // Import your package

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: ExampleScreen(),
    );
  }
}

class ExampleScreen extends StatefulWidget {
  @override
  _ExampleScreenState createState() => _ExampleScreenState();
}

class _ExampleScreenState extends State<ExampleScreen> {
  final amountController = TextEditingController();
  final _amountStreamController = StreamController<String>.broadcast();

  @override
  void dispose() {
    _amountStreamController.close();
    super.dispose();
  }

  Future<void> updateAmountInWords(String digit) async {
    try {
      final doubleAmount = double.parse(digit);
      final words = await digittowordsbd(doubleAmount);
      _amountStreamController.add(words);
    } catch (e) {
      // Handle parsing error
      print('Error: $e');
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Example Screen'),
      ),
      body: Padding(
        padding: const EdgeInsets.all(8.0),
        child: Container(
          height: 200,
          child: Column(
            children: [
              TextFormField(
                controller: amountController,
                keyboardType: TextInputType.number,
                decoration: InputDecoration(labelText: 'Enter Amount'),
                onChanged: (value) {
                  updateAmountInWords(value);
                },
              ),
              SizedBox(height: 20),
              StreamBuilder<String>(
                stream: _amountStreamController.stream,
                builder: (context, snapshot) {
                  if (snapshot.connectionState == ConnectionState.waiting) {
                    return CircularProgressIndicator();
                  } else if (snapshot.hasError) {
                    return Text("Error: ${snapshot.error}");
                  } else {
                    return Text(
                      snapshot.data ?? "",
                      style: TextStyle(
                        fontSize: 16,
                        fontWeight: FontWeight.bold,
                      ),
                    );
                  }
                },
              ),
            ],
          ),
        ),
      ),
    );
  }
}


Additional Information

To report bugs, request features, or contribute to the package, please visit the GitHub repository.

Libraries

digit_to_words_bd
A Dart package to convert numeric digits into their corresponding words representation.