brazilian_locations 3.4.0
brazilian_locations: ^3.4.0 copied to clipboard
Flutter package to display list of States and Cities from Brazil.
Flutter package to display list of States and Cities from Brazil. Brazilian Locations you can build highly customizable input, that your designers can't even draw in Figma 🤭
How to Use #
To use this Package, add brazilian_locations
as a dependency in your pubspec.yaml.
BrazilianLocations(
showStates: true,
showCities: true,
stateDropdownLabel: "State",
cityDropdownLabel: "City",
stateSearchPlaceholder: "State",
citySearchPlaceholder: "City",
onStateChanged: (value) {
if (value != null) {
setState(() => stateValue = value);
}
},
onCityChanged: (value) {
if (value != null) {
setState(() => cityValue = value);
}
},
);
you will get feedback in onChanged functions
Cache Service #
The package now includes a cache service that stores the data retrieved from the IBGE API using Hive, allowing faster loading times for subsequent app launches.
- Optional Initialization:: You can choose to initialize the cache service before running your app to ensure data is preloaded and dropdowns are ready for user interaction immediately.
Example:
void main() async {
/// Optionally initialize BrazilianLocations
/// - Initializes Hive and loads cached data.
/// - Ensures dropdowns are populated and responsive upon first app load.
await BrazilianLocations.initialize();
runApp(const MyApp());
}
Parameters #
Parameters | Type | Description |
showStates | Boolean | Enable disable States dropdown (true / false) |
showCities | Boolean | Enable disable Cities dropdown (true / false) |
dropdownDecoration | BoxDecoration | Dropdown box decoration to style your dropdown selector [OPTIONAL PARAMETER] (USE with disabledDropdownDecoration) |
disabledDropdownDecoration | BoxDecoration | Disabled Dropdown box decoration to style your dropdown selector [OPTIONAL PARAMETER] (USE with disabled dropdownDecoration) |
selectedItemStyle | TextStyle | To change selected item style |
dropdownHeadingStyle | TextStyle | To change DropdownDialog Heading style |
dropdownItemStyle | TextStyle | To change DropdownDialog Item style |
dropdownDialogRadius | double | To change DropdownDialogBox radius |
searchBarRadius | double | To change search bar radius |
stateSearchPlaceholder | String | Placeholder for state search field |
citySearchPlaceholder | String | Placeholder for city search field |
stateDropdownLabel | String | Label/Title for state dropdown |
cityDropdownLabel | String | Label/Title for city dropdown |
Support #
Don't forget to give it a star ⭐