thai_provinces 0.3.1
thai_provinces: ^0.3.1 copied to clipboard
Thailand province/district/subdistrict data with postal codes for Dart & Flutter: offline lookup, search, validation, and address resolution. Pure Dart.
0.3.1 #
- Docs: cite the source dataset — the Department of Provincial Administration (กรมการปกครอง, DOPA) data published on data.go.th — in the data-source section. No code changes.
0.3.0 #
- Add
parseThaiAddress(String) -> ThaiAddressParseResult— a best-effort, never-throwing parser for free-text Thai addresses (the kind people paste from chat/notes/receipts). It recognizes a 5-digit postcode (Arabic or Thai digits), and province / district / subdistrict by their markers (จังหวัด/จ.,อำเภอ/อ./เขต,ตำบล/ต./แขวง, plus theกทม/กรุงเทพฯaliases), then reconciles names against the postcode and pins only the levels it can determine unambiguously — an ambiguous level is leftnullrather than guessed, and the resolved province→district→ subdistrict chain is always internally consistent. ThaiAddressParseResultcarriesprovince/district/subdistrict/postcode(as found) andremainder(the leftover house-number/road text with the matched area tokens and postcode removed), plusisComplete/isEmpty, value equality andtoString().- Pure Dart, no new dependencies — built on the existing lookup primitives.
0.2.0 #
- JSON serialization for every model.
Province,District,SubdistrictandAddressMatchgain atoJson()that emits all fields (self-describing) and afromJsonfactory that reconstructs purely from the map — no dataset lookup. AProvince's region is serialized as its integerregioncode (1..6) and rebuilt viaRegion.fromCode;AddressMatchnests the province/district/ subdistrict JSON. Round-trip guarantee:X.fromJson(x.toJson()) == x(including through a realjsonEncode/jsonDecodestring). - Every
fromJsonfactory throws aFormatException— naming the offending class and key — on any malformed input (an unknown region code, or a missing or wrongly-typed key), so all decode failures share one catchable type. - Integer fields accept a whole-number
double(e.g.2.0) in addition to anint, for tolerance of JSON producers that emit integral values as doubles.
0.1.1 #
- Shorten the package description to pub.dev's 60–180 char range (pub points 150→160). No code changes.
0.1.0 #
- Initial release. Pure-Dart port of
go-thaiaddress. - Embedded dataset: 77 provinces, 928 districts, 7,452 subdistricts with postal codes and six regions, served offline (no network, no files at runtime).
- Lookup by official DOPA geocode:
provinceByCode,districtByCode,subdistrictByCode. - Hierarchy navigation on the models (
Province.districts,District.province,District.subdistricts,District.postcodes,Subdistrict.district,Subdistrict.province) and viadistrictsOf,subdistrictsOf,byPostcode,postcodesOf. - Name layer:
normalizeName(whitespace collapse, lowercasing, admin-prefix stripping), exact finders (findProvinces/findDistricts/findSubdistricts) and prefix autocomplete (searchProvinces/searchDistricts/searchSubdistricts). - Validation and resolution:
validate,resolvewithAddressQuery,AddressMatchandThaiAddressException.