Skip to content
pubscout

flutter_cep2

1.4.0, released 2 weeks ago by vitormelo.dev.br

Brazilian ZIP code (CEP) lookup via ViaCEP, BrasilAPI and OpenCEP with offline validation and cache.

WASM-ready
$ flutter pub add flutter_cep2
Source repository

What it does

Queries Brazilian postal codes (CEPs) using multiple providers with fallback mechanisms. It also supports address-to-CEP searches, coordinate retrieval, and offline format/range validation.

AI-written summary of version 1.4.0, based on the package's README and metadata. Report an inaccuracy

Use it when

  • Building forms that need to auto-complete addresses based on Brazilian CEPs.
  • Looking up latitude and longitude for a given Brazilian ZIP code.
  • Validating and formatting CEP strings offline.

Skip it when

  • You need global postal code lookups outside of Brazil.

Strengths

  • Supports multiple fallback providers (ViaCEP, BrasilAPI, OpenCEP).
  • Includes offline helpers for validation and state detection.
  • Built-in in-memory caching and request timeout handling.

Weaknesses

  • Limited strictly to Brazilian postal codes.
  • Relies on public third-party APIs which may experience downtime or rate limits.

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
3
import 'package:flutter_cep2/flutter_cep2.dart';

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

Alternatives

Packages that do the same job and could replace flutter_cep2.

Works with

Packages commonly used together with flutter_cep2: ones it builds on, ones built on it, and its own family.