Skip to content

About

A Brazilian ZIP code (CEP) lookup library for Dart and Flutter applications. Supports multiple output formats including JSON and XML.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

1 watching

Forks

flutter_cep2

pub package pub points Tests codecov license

Brazilian ZIP code (CEP) lookup library for Dart and Flutter, powered by ViaCEP.

  • Accepts CEPs in any format (01310-100, 01310100, 01.310-100)
  • JSON or XML output
  • Null-safe, well tested
  • Pure Dart — works on every platform

Installation

dependencies:
  flutter_cep2: ^1.0.2
dart pub get

Usage

import 'package:flutter_cep2/flutter_cep2.dart';

Future<void> main() async {
  final cep = FlutterCep2();
  try {
    final result = await cep.search('01310-100');
    print('${result.logradouro}, ${result.bairro} — ${result.localidade}/${result.uf}');
  } on CepException catch (e) {
    print('CEP error: ${e.message}');
  } finally {
    cep.dispose();
  }
}

XML output

await cep.search('01310-100', output: CepOutputFormat.xml);

API

FlutterCep2({http.Client? client})

Creates the service. Accepts an optional http.Client (useful for tests).

Future<Cep> search(String cep, {CepOutputFormat output = CepOutputFormat.json})

Looks up the CEP. Throws CepException for invalid or not-found codes.

void dispose()

Closes the underlying HTTP client.

Cep

Property Type Description
cep String Postal code in XXXXX-XXX format
logradouro String Street/road name
complemento String? Extra address info
bairro String Neighborhood
localidade String City
uf String State (SP, RJ, ...)
unidade String? Postal unit
ibge String IBGE municipality code
gia String? GIA code (São Paulo)
ddd String? Area code
siaf String? SIAF code

Contributing

See CONTRIBUTING.md. Bug reports and PRs welcome.

License

MIT — see LICENSE.

About

A Brazilian ZIP code (CEP) lookup library for Dart and Flutter applications. Supports multiple output formats including JSON and XML.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages