Published on pub.dev • Monorepo

nepal_address & nepal_address_flutter

An offline-first, zero-dependency Dart and Flutter monorepo providing comprehensive administrative division data, bilingual search, structured address formatting, and cascading UI form controls for Nepal's provinces, districts, local levels, and wards.

Author: Pratik Kattel, software developer in Nepal • Publisher on pub.dev: pratikkattel.com.np • License: MIT

pub version: nepal_addresspub version: nepal_address_flutterCI workflow statusMIT License

Package Features

dart

nepal_address

Pure Dart core • Zero runtime dependencies

  • Zero Runtime Dependencies: Pure Dart implementation that runs entirely offline in any Dart or Flutter environment.
  • Relational Administrative Hierarchy: Hierarchical relations from Province → District → Local Level → Ward.
  • Bilingual Models: English and Nepali (Devanagari) names for every province, district, local level, and local level type.
  • Bilingual Search Engine: Search supporting English, Devanagari, and Romanized phonetic spellings, with alias matching and fuzzy tolerance.
  • Structured Address Formatting: SelectedAddress utility for composing, formatting, and serializing addresses in English, Nepali, or bilingual styles.
  • Dataset Provenance & Metadata: Programmatic access to upstream data sources, release dates, and verification metrics via DataInfo.
ui

nepal_address_flutter

Flutter UI package • Built on nepal_address

  • Cascading Selection: Automatically filters downstream options (Province → District → Local Level → Ward) and resets child selections when parents change without losing widget state.
  • Form Integration: NepalAddressFormField integrates seamlessly into Flutter Form widgets with automatic validation, save/reset actions, and multilingual error messages.
  • Standalone Dropdowns: Individual ProvinceDropdown, DistrictDropdown, LocalLevelDropdown, and WardDropdown widgets for customized layouts.
  • Bilingual & Multilingual: Supports English (english), Nepali (nepali), and Bilingual (bilingual — English / नेपाली) label displays.
  • Flexible Visibility: Hide or show individual administrative levels with deterministic fallback rules.
  • Accessible & Customizable: Built on DropdownButtonFormField with stable item keys, accessibility semantics labels, and full InputDecoration theming.

Installation & Setup

Dart / Server / CLI (Core lookups & search)

terminalbash
dart pub add nepal_address

Flutter Apps (Pickers, dropdowns & form fields)

terminalbash
flutter pub add nepal_address_flutter

pubspec.yaml dependencies

pubspec.yamlyaml
dependencies:
  nepal_address: ^0.1.0
  nepal_address_flutter: ^0.1.0

Import statements

lib/main.dartdart
import 'package:nepal_address/nepal_address.dart';
import 'package:nepal_address_flutter/nepal_address_flutter.dart';

Quick Usage Examples

1. Pure Dart: Data Queries, Bilingual Search & Formatting

nepal_address
example/main.dartdart
import 'package:nepal_address/nepal_address.dart';

void main() {
  // Hierarchical Queries
  final districtsInKoshi = NepalAddress.getDistrictsByProvinceId(1);
  for (final d in districtsInKoshi) {
    print('${d.nameEn} (${d.nameNp})');
  }

  final localLevelsInBhojpur = NepalAddress.getLocalLevelsByDistrictId(1);
  final wardsInShadanand = NepalAddress.getWardsByLocalLevelId(1);

  // Bilingual & Phonetic Search
  final englishResults = NepalAddress.search('Kathmandu');
  final nepaliResults = NepalAddress.search('काठमाडौँ');
  final phoneticResults = NepalAddress.search('Katmandu'); // Matches "Kathmandu"

  // Structured Address Formatting
  final address = SelectedAddress.fromEntities(
    province: NepalAddress.getProvinceById(3),
    district: NepalAddress.getDistrictById(27),
    localLevel: NepalAddress.getLocalLevelById(307),
    wardNumber: 1,
  );

  print(address.en);        // "Ward 1, Kathmandu, Kathmandu, Bagmati Province"
  print(address.np);        // "वडा नं. १, काठमाण्डौं, काठमाडौँ, बाग्मती प्रदेश"
  print(address.bilingual); // "Ward 1 (वडा नं. १), Kathmandu (काठमाण्डौं)..."
}

2. Flutter: Cascading FormField & AddressPicker

nepal_address_flutter
example/lib/main.dartdart
import 'package:flutter/material.dart';
import 'package:nepal_address/nepal_address.dart';
import 'package:nepal_address_flutter/nepal_address_flutter.dart';

// 1. Integration inside a standard Flutter Form with built-in validation
NepalAddressFormField(
  showWard: true,
  language: NepalAddressLanguage.bilingual,
  requiredLevels: const {
    NepalAddressLevel.province,
    NepalAddressLevel.district,
    NepalAddressLevel.localLevel,
    NepalAddressLevel.ward,
  },
  onSaved: (SelectedAddress? address) {
    print('Saved Address: ${address?.bilingual}');
  },
)

// 2. Standalone Cascading Picker for custom workflows
NepalAddressPicker(
  showWard: true,
  language: NepalAddressLanguage.english,
  initialValue: const SelectedAddress(provinceId: 1),
  onChanged: (SelectedAddress address) {
    print('Selected: ${address.en}');
  },
)

Tech Stack & Engineering Standards

Zero Runtime Dependencies

Core package has 0 third-party runtime package dependencies. Pure Dart implementation ensuring fast compilation and minimal bundle size.

SDK Compatibility

nepal_address: Dart >=3.8.0 <4.0.0
nepal_address_flutter: Dart >=3.9.0, Flutter >=3.35.0

GitHub Actions CI

Continuous integration tested across minimum SDKs (Dart 3.8.0, Flutter 3.35.0) and latest stable channels, including automated code formatting checks.

Offline-First Embedded DB

Pre-compiled static data tables embedded directly in Dart code. Works 100% offline with zero network requests or local database daemons.

Automated Test Coverage

Comprehensive unit and widget tests covering data integrity, search ranking order, phonetic matching, and cascading dropdown state resets.

Verified Publisher

Published on pub.dev under the publisher domain pratikkattel.com.np with standard semantic versioning (0.1.0).

Dataset Provenance & Known Limitations

This dataset is compiled and cross-checked from three open MIT-licensed sources:

  • sagautam5/local-states-nepal (primary source)
  • younginnovations/nepal-locallevel-map (secondary source)
  • bedbyaspokhrel/nepal-geo-data (tertiary source)

Important: This package is not an official government dataset, nor is it endorsed by the Government of Nepal or the Ministry of Federal Affairs and General Administration (MoFAGA).

A total of 12 known source conflicts in ward counts or municipality classifications could not be reconciled definitively and are cataloged as unverified in the codebase. Spatial boundary polygons, GeoJSON shapes, and centroid coordinates are deliberately excluded to maintain a zero-dependency lightweight pure Dart library.