format_amount_service library

Format Amount Service Library

A Flutter library for formatting amounts and IBAN numbers with a clean, efficient singleton design pattern.

This library provides:

  • Amount formatting with thousands separators
  • Currency conversion from halalah to riyals (Saudi currency)
  • IBAN formatting with proper spacing
  • Singleton design pattern for efficient memory usage
  • Comprehensive testing and examples

Quick Start

import 'package:format_amount_service/format_amount_service.dart';

// Get the singleton instance
final formatter = FormatAmountService.instance;

// Format an amount
final formatted = formatter.formatAmount('100000'); // Returns "1,000.00"

// Format IBAN
final iban = formatter.formatIBAN('SA0380000000608010167519');
// Returns "SA03 8000 0000 6080 1016 7519"

Features

  • Amount Formatting: Convert numeric strings to display format with thousands separators
  • Currency Conversion: Handle halalah to riyals conversion (Saudi currency)
  • IBAN Formatting: Format IBAN numbers with proper spacing for readability
  • Singleton Pattern: Memory-efficient single instance design
  • Null Safety: Full null safety support
  • Comprehensive Documentation: Well-documented with usage examples
  • Testing: Full test coverage included

Architecture

The library follows clean architecture principles:

  • Service Layer: Core formatting logic
  • Singleton Pattern: Efficient memory usage
  • Error Handling: Graceful handling of edge cases
  • Performance: Optimized for production use

Usage Examples

See example_usage.dart for comprehensive examples and README.md for detailed documentation.

Testing

Run tests with:

flutter test

Classes

FormatAmountService
A service class for formatting amounts and IBAN numbers.