flutter_cep2 1.1.0
flutter_cep2: ^1.1.0 copied to clipboard
Brazilian ZIP code (CEP) lookup for Dart and Flutter, backed by the ViaCEP API. JSON or XML, typed model, clear errors, every platform.
Changelog #
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
1.1.0 - 2026-11-03 #
Fixed #
- A missing CEP now throws
CepException('ZIP code not found'): ViaCEP sends"erro": "true"as a string, which used to return an emptyCep. siafis filled again: ViaCEP names the fieldsiafi.- A malformed body is reported as
Invalid response, notNetwork error. dispose()no longer closes anhttp.Clientpassed to the constructor.- The README said MIT; the package is licensed under LGPL-2.1, as in
LICENSE. - Accented text (
São Paulo) is no longer garbled when the answer comes without a charset header: the body is always read as UTF-8.
Added #
searchAddress(uf, city, street): lists the CEPs of a street, from ViaCEP's/ws/UF/city/street/search, in JSON or XML.CepException.type(CepErrorType), so callers can tell a missing CEP from a network failure without matching the message.Cep.estadoandCep.regiao, sent by ViaCEP.timeoutin the constructor (10 seconds by default); a slow request throwsCepException('Request timed out')and the request is aborted, so the connection does not stay open.
Changed #
- Minimum Dart SDK is declared as 3.0, the real minimum of the dependencies (it said 2.17).
- Dependency ranges:
http^1.5.0 (needed to abort a timed-out request),meta^1.9.0. - XML answers are read with
package:xmldirectly instead of being converted to JSON text and decoded again; thexml2jsondependency is gone. Empty XML fields (<unidade></unidade>) now come as'', the same as in JSON, instead ofnull. - The library is split into
Cep,CepExceptionandFlutterCep2files; the public API and import are unchanged. - Example: guards against updating the screen after it is closed; shows the state name and region.
1.0.0 - 2025-08-07 #
Rewrite with null safety.
Added #
FlutterCep2service with an injectablehttp.Clientanddispose().CepOutputFormatenum (JSON, XML).CepExceptionfor every failure.- Immutable
Cepmodel with value equality,fromJsonandtoJson. - Accepts CEPs with or without formatting.
- API documentation and tests.
Changed #
- Breaking:
flutter_cep2class renamed toFlutterCep2andCEPtoCep(the old names remain as deprecated aliases). - Breaking: the output format is a
CepOutputFormatinstead of aString. - Moved from
pedantictolints.
Removed #
- Breaking: the
pipedandquertyformats, which never worked.