cpf_utility 1.0.0 copy "cpf_utility: ^1.0.0" to clipboard
cpf_utility: ^1.0.0 copied to clipboard

Generate, validate and format valid Brazilian CPF's.

CPF Utility #

A simple package that provides CPF utilities.

A CPF is an 11 digit number which is the Brazilian individual identity number.

Example of a formatted CPF: 321.524.051-37

Usage #

To generate a valid CPF simply:

String myCpf = Cpf.generate();

If you want to generate a valid CPF from a given Brazilian state you can use the State enum:

String myCpf = Cpf.generate(state: States.sp);

The CPF comes formatted by default, you can make it unformatted:

String myCpf = Cpf.generate(formatted: false);

If you have an unformatted CPF and want to format it:

String myCpf = Cpf.generate(formatted: false); // 32152405137
String formattedCpf = Cpf.format(myCpf);       // 321.524.051-37

Or maybe you want to strip your formatted CPF:

String unformattedCpf = Cpf.strip(formattedCpf); // 32152405137

And you can validate a formatted or unformatted CPF:

if (validateCpf(myCpf)) {
  print("CPF is valid");
} else {
  print("CPF isn't valid");
}
0
likes
120
pub points
53%
popularity

Publisher

unverified uploader

Generate, validate and format valid Brazilian CPF's.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (LICENSE)

More

Packages that depend on cpf_utility