FLUTTER ECOSYSTEM

leancodepl/address

국제화 라이브러리 처리. 다양한 언어로 다양한 물리적 주소를 형식화하고 지역화된 주소 양식을 구축합니다.

주소 프로젝트 이미지
Stars
12
Forks
1
최근 푸시(UTC)
2023. 8. 15.
프로젝트 상태
활성
LeanCode GitHub avatar
GITHUB Organization

LeanCode ↗

We're a custom software studio that delivers end-to-end solutions for various industries. Experts in Flutter, .NET, and React.

언어DartSwiftKotlinObjective-C

기술 주제

이 저장소가 배포한 패키지

사용 중인 의존성

의존성 목록 3 개
  • meta^1.3.0
  • lint개발 의존성^1.5.1
  • test개발 의존성^1.16.4

원본 README

아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.

README 펼치기 / 접기

address

Pub Version GitHub test workflow status

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:

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:

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.

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.