agani_id_formatter 1.0.0
agani_id_formatter: ^1.0.0 copied to clipboard
Comprehensive Indonesian data formatter and validator. Format and validate Rupiah, NIK, NPWP, phone numbers, postal codes, bank accounts, dates, and more.
import 'package:flutter/material.dart';
import 'package:agani_id_formatter/agani_id_formatter.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Agani ID Formatter Demo',
theme: ThemeData(primarySwatch: Colors.blue, useMaterial3: true),
home: const DemoPage(),
);
}
}
class DemoPage extends StatelessWidget {
const DemoPage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Agani ID Formatter Demo')),
body: ListView(
padding: const EdgeInsets.all(16),
children: [
_buildSection('Rupiah Formatter', [
Text('Format: ${RupiahFormatter.format(1500000)}'),
Text(
'With decimal: ${RupiahFormatter.format(1500.75, decimal: 2)}',
),
Text('Negative: ${RupiahFormatter.format(-250000)}'),
]),
_buildSection('NIK Formatter & Validator', [
Text('Format: ${NIKFormatter.format('3201234567890123')}'),
Text('Valid: ${NIKValidator.validate('3201234567890123')}'),
Text('Extract: ${NIKFormatter.extract('3201234567890123')}'),
]),
_buildSection('NPWP Formatter & Validator', [
Text('Format: ${NPWPFormatter.format('123456789012345')}'),
Text('Valid: ${NPWPValidator.validate('123456789012345')}'),
]),
_buildSection('Phone Formatter & Validator', [
Text('Local: ${PhoneFormatter.format('081234567890')}'),
Text(
'International: ${PhoneFormatter.format('081234567890', format: 'international')}',
),
Text('Operator: ${PhoneValidator.getOperator('081234567890')}'),
Text('Valid: ${PhoneValidator.validate('081234567890')}'),
]),
_buildSection('Date Formatter', [
Text('Long: ${IndonesianDateFormatter.format(DateTime.now())}'),
Text(
'Full: ${IndonesianDateFormatter.format(DateTime.now(), format: 'full')}',
),
]),
_buildSection('Province Data', [
Text('Province 32: ${IndonesiaProvinces.getProvinceName('32')}'),
Text(
'Total: ${IndonesiaProvinces.getAllProvinceNames().length} provinces',
),
]),
_buildSection('Bank Data', [
Text('Bank 014: ${IndonesiaBanks.getBankName('014')}'),
Text('Total: ${IndonesiaBanks.getAllBankNames().length} banks'),
]),
_buildSection('E-Wallet Data', [
Text(
'E-Wallets: ${IndonesiaEWallets.getAllEWalletNames().join(', ')}',
),
]),
],
),
);
}
Widget _buildSection(String title, List children) {
return Card(
margin: const EdgeInsets.only(bottom: 16),
child: Padding(
padding: const EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
title,
style: const TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
),
const SizedBox(height: 12),
...children,
],
),
),
);
}
}