๐Ÿ“ฆ pincode_address_picker

A complete Flutter package to pick and validate Country โ†’ State โ†’ City using dropdowns or typeaheads, or auto-fill them by entering a pincode/postal code.

Perfect for apps that collect addresses: e-commerce, delivery, registration, checkout, etc.


โœจ Features

  • ๐Ÿ“ Pincode to City/State auto-detection
  • ๐ŸŒ Built-in dataset of countries, states, and cities (with lat/lng and postal info)
  • ๐Ÿงฉ Customizable UI layouts (4x1 column or 2x2 grid)
  • ๐ŸŽฏ RegEx-based validation for postal codes by country
  • ๐Ÿ”ง Exposed utility APIs if you want to use your own UI
  • โšก Fast, offline lookups with no runtime API calls

๐Ÿš€ Getting Started

1. Add to pubspec.yaml

dependencies:
  pincode_country_state_city_pro: ^0.1.0

2. Usage

Using the default picker UI

final controller = AddressPickerController();

PincodeCountryStateCityPicker(
  controller: controller,
  gridType: GridType.grid4x1, // or GridType.grid2x2
  showCountryFlag: true //show the country flag
)
Pincode Address Picker Image Pincode Address Picker Demo

๐Ÿ–ผ Layout Options

Support two pre-defined layouts:

GridType.grid4x1 โ†’ All fields in vertical column

GridType.grid2x2 โ†’ 2ร—2 compact grid

๐Ÿ›  AddressPickerController

This controller helps you manage and listen to the selected country, state, city, and pincode.

final controller = AddressPickerController();

controller.selectedCountry.addListener(() {
  print(controller.selectedCountry.value?.name);
});

Get selected values

controller.selectedCountry.value;
controller.selectedState.value;
controller.selectedCity.value;

๐Ÿงช If You Want Only the Data

You can use the utility APIs without the picker UI.

๐Ÿ—บ Get Countries

List<Country> countries = await getAllCountries();
Country? india = await getCountryByIsoCode(isoCode: "IN");

๐Ÿ™ Get States

List<StateModel> states = await getStatesOfCountry(countryCode: "IN");
StateModel? state = await getStateByCode(countryCode: "IN", stateCode: "TG");

๐Ÿก Get Cities

List<City> cities = await getCitiesOfState(countryCode: "IN", stateCode: "AP");
City? city = await getCityByPostalCode(postalCode: "502103", countryCode: "TG");

๐Ÿ—บ ๐Ÿ™ ๐Ÿก Get Address(State, City) from postalCode

AddressData addressData = await getStateAndCityByPostalCode(postalCode: "502103", countryCode: "IN");
State state = addressData.state;
City city = addressData.city;

Get PostalCodeFormat from countryCode

PostalCodeFormat? postalCodeFormat = getPostalFormatFromCountryCode(countryCode : "IN");
For more APIs, check this file

Additional information

๐Ÿ™Œ Contributing : Found a bug? Want to add more data or improve UX? PRs are welcome!! Open issues, contribute, or star the repo ๐Ÿ’™