NIK Parser

A Dart package for parsing and validating Indonesian NIK (Nomor Induk Kependudukan) numbers.

Installation

Add this to your pubspec.yaml:

dependencies:
  nik_parser: ^0.0.1

Usage

import 'package:nik_parser/nik_parser.dart';

void main() {
  // Load your wilayah.json data
  final provinsi = {...}; // Your province data
  final kabkot = {...}; // Your district/city data
  final kecamatan = {...}; // Your subdistrict data

  final parser = NikParser(
    provinsi: provinsi,
    kabkot: kabkot,
    kecamatan: kecamatan,
  );

  final nikDetail = parser.parse('1234567890123456');

  // Validate NIK
  print(nikDetail.isValid()); // true or false

  // Get NIK details
  print(nikDetail.province()); // Province name
  print(nikDetail.kabupatenKota()); // District/City name
  print(nikDetail.kecamatan()); // Subdistrict name
  print(nikDetail.kelamin()); // Gender (pria/wanita)
  print(nikDetail.lahir()); // Birth date
  print(nikDetail.kodepos()); // Postal code
}

Features

  • Validate NIK format
  • Extract province, district, and subdistrict information
  • Determine gender
  • Get birth date
  • Retrieve postal code

License

MIT License


## Notes for Usage

1. This Dart package follows a similar structure to the original TypeScript implementation.
2. The main differences are:
   - Uses Dart's null safety
   - Slightly modified error handling
   - DateTime handling adapted to Dart
3. You'll need to provide the `wilayah.json` data when initializing the `NikParser`

## Recommendations

- Add proper error handling for invalid NIK formats
- Create comprehensive unit tests
- Consider adding more detailed documentation

Would you like me to elaborate on any part of the package or explain the conversion process?

Libraries

nik_parser