Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/leancodepl/address
Addresses internationalization library. Format various physical addresses in various languages and build localized address forms.
https://github.com/leancodepl/address
address dart i18n l10n
Last synced: 6 days ago
JSON representation
Addresses internationalization library. Format various physical addresses in various languages and build localized address forms.
- Host: GitHub
- URL: https://github.com/leancodepl/address
- Owner: leancodepl
- License: apache-2.0
- Created: 2021-02-25T15:38:01.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-08-15T15:09:05.000Z (about 1 year ago)
- Last Synced: 2024-08-01T12:28:04.669Z (3 months ago)
- Topics: address, dart, i18n, l10n
- Language: Dart
- Homepage: https://pub.dev/packages/address
- Size: 112 KB
- Stars: 9
- Watchers: 4
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# address
[![Pub Version][pub-badge]][pub-link]
[![GitHub test workflow status][build-badge]][build-link]Addresses internationalization library. Format various physical addresses in various languages and build localized address forms.
## Usage
### Formatting address to display
Given you have some address:
```dart
final address = Address(
fullName: 'Nicole Martin',
addressLine1: '123 Sherbrooke St',
city: 'Montreal',
zone: 'QC',
postalCode: 'H3G 2A6',
country: 'CA',
);
```You can format it to your desired format:
```dart
final englishFormatter = AddressFormatter('en');
print(englishFormatter.formatDisplay(address));// [
// 'NICOLE MARTIN',
// '123 SHERBROOKE ST',
// 'MONTREAL QC H3G 2A6',
// 'CANADA'
// ]final frenchFormatter = AddressFormatter('fr');
print(frenchFormatter.formatDisplay(address));// [
// 'Nicole Martin',
// '123 Sherbrooke St',
// 'Montreal (Québec) H2G 2A6',
// 'CANADA'
// ]
```## Address form layout
You can also get localized format of an address form with all obligatory and optional fields along with their labels and descriptions.
```dart
final addressFormatter = AddressFormatter('en');
final formFormat = addressFormatter.formatForm('US');// formFormat = [
// // other fields: full name, addressLine1, addressLine2, city
// AddressFormFieldInformation(
// label: 'State',
// obligatory: true,
// availableValues: {
// // (...)
// 'TX': 'Texas',
// // (...)
// },
// ),
// // other fields: zip code
// ]
```You can use this information to build e.g. a Flutter form. You can see how to do this by looking into the [example][example].
[pub-link]: https://pub.dev/packages/address
[pub-badge]: https://img.shields.io/pub/v/address
[build-link]: https://github.com/leancodepl/address/actions/workflows/test.yml
[build-badge]: https://img.shields.io/github/actions/workflow/status/leancodepl/address/test.yml?branch=main
[example]: example