pcic_location_package 1.0.1
pcic_location_package: ^1.0.1 copied to clipboard
A Dart package containing Philippine location data (Provinces, Municipalities, Barangays)
PCIC Location Package #
A Flutter package containing comprehensive Philippine location data including provinces, municipalities, and barangays.
Features #
- Complete database of Philippine provinces
- Complete database of municipalities
- Complete database of barangays
- Easy-to-use service for filtering locations by region, province, and municipality codes
- Simple data models for Province, Municipality, and Barangay
Getting Started #
Add this to your package's pubspec.yaml file:
dependencies:
pcic_location_package: ^1.0.0
Then run:
flutter pub get
Usage #
Import the package:
import 'package:pcic_location_package/pcic_location_package.dart';
Load All Provinces #
final locationService = LocationService();
List<Province> provinces = await locationService.loadProvinces();
for (var province in provinces) {
print('${province.provinceName} (Code: ${province.provinceCode})');
}
Get Municipalities by Province #
// Get all municipalities for province code "1" (Abra)
List<Municipality> municipalities = await locationService.getMunicipalitiesByProvince('1');
Get Barangays by Municipality #
// Get all barangays for municipality code 1
List<Barangay> barangays = await locationService.getBarangaysByMunicipality(1);
Get Specific Province #
Province? province = await locationService.getProvinceByCode('1');
if (province != null) {
print('Province: ${province.provinceName}');
}
Example #
Here's a complete example showing a dropdown of provinces:
import 'package:flutter/material.dart';
import 'package:pcic_location_package/pcic_location_package.dart';
class ProvinceDropdown extends StatefulWidget {
@override
_ProvinceDropdownState createState() => _ProvinceDropdownState();
}
class _ProvinceDropdownState extends State<ProvinceDropdown> {
final LocationService _locationService = LocationService();
List<Province>? _provinces;
Province? _selectedProvince;
@override
void initState() {
super.initState();
_loadProvinces();
}
Future<void> _loadProvinces() async {
final provinces = await _locationService.loadProvinces();
setState(() {
_provinces = provinces;
});
}
@override
Widget build(BuildContext context) {
if (_provinces == null) {
return CircularProgressIndicator();
}
return DropdownButton<Province>(
value: _selectedProvince,
hint: Text('Select Province'),
items: _provinces!.map((province) {
return DropdownMenuItem(
value: province,
child: Text(province.provinceName),
);
}).toList(),
onChanged: (Province? newValue) {
setState(() {
_selectedProvince = newValue;
});
},
);
}
}
Data Models #
Province #
provinceID: Unique province identifierregionNo: Region numberprovinceCode: Province codeprovinceName: Province name
Municipality #
municipalityID: Unique municipality identifierregionNo: Region numberprovinceCode: Province codemunicipalityCode: Municipality codemunicipalityName: Municipality name
Barangay #
barangayID: Unique barangay identifierbarangayCode: Barangay codebarangayName: Barangay namemunicipalityCode: Municipality code
License #
This project is licensed under the MIT License - see the LICENSE file for details.