Search packages, repositories and app categories

Package detailsv1.0.3

cpfcnpj

An easy-to-use utility for CPF/CNPJ validation and formatting.

30-day downloads
176
Likes
51
Pub points
30

Install package

flutter pub add cpfcnpj

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

A lightweight Flutter/Dart package designed for validating and formatting Brazilian CPF (individual taxpayer registry) and CNPJ (corporate taxpayer registry) numbers. It provides simple, reliable methods to check the correctness of CPF/CNPJ formats, automatically apply standard formatting (e.g., 123.456.789-01), and ensure data integrity during user input. Ideal for forms requiring Brazilian tax identification validation, it supports both client-side validation and real-time masking. The package is easy to integrate and maintains clean, readable code with minimal dependencies.

Use cases

  • Form input validation
  • Real-time CPF/CNPJ formatting
  • Data integrity checks
  • Brazilian tax ID processing
  • User registration flows

Key features

  • CPF/CNPJ validation
  • Automatic formatting
  • Simple API
  • Lightweight
  • Client-side validation support

Suitable for

  • Brazilian applications
  • User registration systems
  • Financial forms
  • Mobile apps requiring tax IDs
  • Input masking utilities

Considerations

  • Only supports Brazilian CPF/CNPJ
  • No international tax ID support
  • Requires manual handling of edge cases
  • Limited to validation and formatting
  • No built-in error messages

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

An easy-to-use utility for CPF/CNPJ validation and formatting.

Usage

A simple usage example:

import 'package:cpfcnpj/cpfcnpj.dart';

main() {
  
  // Validar CPF
  if (CPF.isValid("123.717.730-86")) {
    print("Este CPF é válido.");
  } else {
    print("Este CPF é inválido.");
  }

  // Validar CNPJ
  if (CNPJ.isValid("43.814.971/0001-89")) {
    print("Este CNPJ é válido.");
  } else {
    print("Este CNPJ é inválido.");
  }

  // Formatar CPF
  print(CPF.format("12371773085")); // 123.717.730-85

  // Formatar CNPJ
  print(CNPJ.format("43814971000188")); // 43.814.971/0001-88

}

Features and bugs

Please file feature requests and bugs at the issue tracker.

Categories

Source repository

Projects using this package

No data available yet.