๐Ÿ“ฆ 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

  • โšก Fully offline address picker (no runtime API calls)
  • ๐Ÿ“ Auto-detect State and City from Pincode / Postal Code
  • ๐ŸŒ Built-in dataset of countries, states, and cities
  • ๐ŸŽฏ RegEx-based country-specific postal code validation
  • ๐Ÿงฉ Custom layouts using individual picker widgets
  • ๐Ÿ”Ž Supports DropdownSearch and TypeAheadSearch
  • ๐Ÿ”ง Utility APIs if you want to build your own UI

Pincode Address Picker Image Pincode Address Picker Demo

๐Ÿš€ Getting Started

1. Add to pubspec.yaml

dependencies:
  pincode_country_state_city_pro: ^1.0.0

2. Quick Start

Using the default picker UI

final controller = AddressPickerController();

PincodeCountryStateCityPicker(
  controller: controller,
)

Custom Layout

You can build your own layouts using the individual pickers provided by the package.

//All pickers automatically stay in sync using the same controller.
final controller = AddressPickerController();

Column(
  children: [
    Row(
      children: [
        CountryPicker(
          pickerProps: PickerProps(controller: controller),
        ),
        PincodeField(controller: controller),
      ],
    ),
    Row(
      children: [
        StatePicker(),
        CityPicker(),
      ],
    ),
  ],
)

๐Ÿ›  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 ๐Ÿ’™

Libraries

pincode_country_state_city_pro
Offline-first Flutter package providing country, state, and city dropdowns with typeahead search, pincode-based auto-fill, and country-specific postal code validation.