Strict BACEN EMV Pix payloads and QR rendering in pure Dart.
Brazil's instant payment network (Pix) relies on the Banco Central do Brasil (BCB) BR Code specification—an EMV Merchant-Presented QR format where a single malformed TLV length prefix or off-spec CRC16 checksum causes banking apps to reject a payment.
br_code_pix implements Static and Dynamic (Cob / CobV) BR Code generation directly in pure Dart, automating TLV field formatting, Brazilian Portuguese diacritic sanitization, field-length clamping, and strict CRC16-CCITT calculation.
With zero native platform dependencies, the library runs uniformly across Android, iOS, Web, macOS, Windows, Linux, and WebAssembly—and includes an out-of-the-box BrCodePixWidget for instant QR presentation in Flutter.
Drop-in installation and Dart API.
Published as br_code_pix on pub.dev (v1.0.0, published Feb 25, 2026) with 160 / 160 pub points.
dependencies:
br_code_pix: ^1.0.0final staticPayload = BrCodePix.generateStatic(
pixKey: '+5511999999999',
merchantName: 'MINHA LOJA PIX',
merchantCity: 'SAO PAULO',
amount: 35.50,
txid: 'PGTO123',
);
BrCodePixWidget.staticPix(
pixKey: '+5511999999999',
merchantName: 'MINHA LOJA PIX',
merchantCity: 'SAO PAULO',
amount: 35.50,
);Precision EMV formatting without bloat.
Deterministic TLV field serialization, diacritic normalization, and mathematical CRC16 verification following BCB rules.
Strict ID + Length + Value Serialization
EmvUtil.formatField encodes every EMV tag using two-digit zero-padded lengths—assembling Payload Format (00), Pix GUI br.gov.bcb.pix (26), MCC (52), BRL currency 986 (53), optional amount (54), country BR (58), and TXID template (62).
BACEN CRC16-CCITT Verification
Crc16.calculate computes the 16-bit checksum across the complete payload plus tag 6304 using polynomial 0x1021 and initial value 0xFFFF, formatting uppercase 4-hex digits guaranteed to pass bank QR scanners.
Static & Dynamic (Cob / CobV) Flows
Supports static charges with CPF, CNPJ, email, phone, or EVP random keys as well as dynamic PSP payload URLs (strip scheme into subfield 26-25 with '***' TXID per BACEN spec 2.6.1).
ASCII Sanitization & Flutter QR Widget
EmvUtil.sanitizeStr normalizes Portuguese accents, strips unsupported punctuation, uppercases, and clamps merchant names (25 chars) and cities (15 chars). BrCodePixWidget wraps qr_flutter with custom colors and embedded logo support.
Supported Modes, Fields & Targets
- Tag 00: Payload Format Indicator ('01')
- Tag 26: br.gov.bcb.pix (Key 01 or URL 25)
- Tags 52–58: MCC 0000, Currency 986 (BRL), BR
- Tags 59–60: Sanitized Merchant Name & City
- Tags 62 & 63: TXID Reference & CRC16-CCITT
- BrCodePix.generateStatic(...)
- BrCodePix.generateDynamic(...)
- BrCodePixWidget & .staticPix / .dynamicPix
- Crc16.calculate(payload)
- EmvUtil.formatField & EmvUtil.sanitizeStr
- Android & iOS mobile apps
- Web & WebAssembly (is:wasm-ready)
- macOS, Windows & Linux desktop
- Zero native C++ or platform channels
- Depends only on Flutter + qr_flutter ^4.1.0