flutter_cep2 1.3.0
flutter_cep2: ^1.3.0 copied to clipboard
Busca de CEP para Dart e Flutter: ViaCEP, BrasilAPI e OpenCEP com fallback, cache, coordenadas e validação offline. Brazilian ZIP code (CEP) lookup.
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.
[Unreleased] #
1.3.0 - 2026-11-05 #
Added #
Cep.provider: whichCepProvideranswered, kept bytoJson/fromJsonand the cache.Cep.isCityWide: true when the CEP has no street, as in towns with a single CEP, so a form knows to ask for it.- README: whole-city CEPs and why providers can agree on a wrong record.
1.2.1 - 2026-11-04 #
Changed #
- The Example tab on pub.dev shows short recipes (lookup, fallback and cache, address search, coordinates, offline helpers, error messages) before the Flutter app.
- Description and README summary in Portuguese, so the package shows up when searching for "busca de CEP".
1.2.0 - 2026-11-04 #
Added #
providers:searchcan fall back to BrasilAPI and OpenCEP (CepProvider) when ViaCEP fails or does not know the CEP. ViaCEP alone is still the default.cacheDuration: keeps successful answers ofsearchandsearchAddressin memory (up to 1000), so repeated lookups skip the network. Off by default.Cep.latitudeandCep.longitude, filled by BrasilAPI (now queried on its v2 API) when it knows the point.- Offline helpers:
isValidCep,formatCepandcepState, which gives the state and region from the Correios CEP ranges with no request.
1.1.1 - 2026-11-04 #
Changed #
- README rewritten: banner, feature table, address search, error table, FAQ.
- The pub.dev page shows a screenshot of the example app.
- Example: field labels such as "Neighborhood" no longer break mid-word.
- CI: coverage reaches Codecov again (upload via OIDC), so the badge works.
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.
