BJ Location Data

Benin Republic location data for web and mobile apps

For javascript version, please visit location_data_bj npm package

For raw data version, please visit bj_location_data_raw repository

Data Snapshot (As of 2023-12-21)

Department: 12

Town: 77

District: 546

Neighborhood: 5303

The code used in the dataset is an auto generated code. Please refer to the bj_location_data_raw repository for more information.


Note:

  • This package is pure dart package. It can be used in all platforms supported by dart.

  • For flutter users, note that we don't provide any widget for now. Feel free to contribute.

Installation

In the dependencies: section of your pubspec.yaml, add the following line:

dependencies:
  location_data_bj: <latest_version>

API Usage:

  1. Get all departments
List<Department> departments = LocationData.departmentList(sortBy: 'asc');
  1. Get all towns
List<Town> towns = LocationData.townsList(sortBy: 'asc');
  1. Get all districts
List<District> districts = LocationData.districtList(sortBy: 'asc');
  1. Get all neighborhoods
List<Neighborhood> neighborhoods = LocationData.neighborhoodList(sortBy: 'asc');
  1. Get department by code
Department? department = LocationData.department('cot');
  1. Get town by code
Town? town = LocationData.town('cot');
  1. Get district by code
District? district = LocationData.district('cot');
  1. Get neighborhood by code
Neighborhood? neighborhood = LocationData.neighborhood('cot');
  1. Get towns of department
List<Town> towns = LocationData.townsOfDepartment('cot', sortBy: 'asc');
  1. Get districts of town
List<District> districts = LocationData.districtsOfTown('cot', sortBy: 'asc');
  1. Get neighborhoods of district
List<Neighborhood> neighborhoods = LocationData.neighborhoodsOfDistrict('cot', sortBy: 'asc');
  1. Search data
List<LocationEntity> result = LocationData.searchData('cot', sortBy: 'asc');
  1. Search departments
List<Department> result = LocationData.searchDepartments('cot', sortBy: 'asc');
  1. Search towns
List<Town> result = LocationData.searchTowns('cot', sortBy: 'asc');
  1. Search districts
List<District> result = LocationData.searchDistricts('cot', sortBy: 'asc');
  1. Search neighborhoods
List<Neighborhood> result = LocationData.searchNeighborhoods('cot', sortBy: 'asc');

Data Model:

  1. Base LocationEntity
abstract class LocationEntity {
  String code;
  String name;

  LocationEntity({
    required this.code,
    required this.name,
  });
}
  1. Department
class Department implements LocationEntity {
  @override
  final String code;
  @override
  final String name;

  Department({
    required this.code,
    required this.name,
  });
}
  1. Town
class Town implements LocationEntity {
  @override
  final String code;
  @override
  final String name;
  final String departmentCode;

  Town({
    required this.code,
    required this.name,
    required this.departmentCode,
  });
}
  1. District
class District implements LocationEntity {
  @override
  final String code;
  @override
  final String name;
  final String townCode;

  District({
    required this.code,
    required this.name,
    required this.townCode,
  });
}
  1. Neighborhood
class Neighborhood implements LocationEntity {
  @override
  final String code;
  @override
  final String name;
  final String districtCode;

  Neighborhood({
    required this.code,
    required this.name,
    required this.districtCode,
  });
}

Disclaimer

Please note that the dataset used is not official. It is based on the work done by Junior Gantin at this repo.

License

Bj Location Data is crafted with ❤️ by Dah-Kenangnon Justin and is open-sourced software licensed under the MIT license.

These person has helped me for cleaning the data and making it easier to use in dart and javascript:

Libraries

location_data_bj
Benin Republic location data for web and mobile apps