Skip to content

Dart utils library for specific Brazilian businesses

License

Notifications You must be signed in to change notification settings

HenriqueNas/brutils-dart

Repository files navigation

BR Utils Dart

pub package coverage License: MIT style: very good analysis

Utils library for specific Brazilian businesses

Installation 💻

❗ In order to start using brutils-dart you must have the Dart SDK installed on your machine.

Add br_utils to your pubspec.yaml:

dependencies:
  br_utils:

Or install it with pub cli:

dart pub add br_utils

Usage 📖

BRUtils

import 'package:br_utils/br_utils.dart';

void main() {
  final String cpf = BRUtils.cpf.generate();
  final bool validCpf = BRUtils.cpf.isValid(cpf);
  final String cpfMask = BRUtils.cnpj.mask();

  final String cnpj = BRUtils.cnpj.generate();
  final bool validCnpj = BRUtils.cnpj.isValid(cnpj);
  final String cnpjMask = BRUtils.cnpj.mask();
}

CPF

import 'package:br_utils/br_utils.dart';

void main() {
  // Create a new CPF instance
  final cpf = CPF('12345678909');
  print(cpf.isValid); // true
  print(cpf.unmask()); // 12345678909

  // Use CPF static methods
  print(CPF.isValidCPF('12345678909')); // true
  print(CPF.generateCPF()); // 12345678909
}

CNPJ

import 'package:br_utils/br_utils.dart';

void main() {
  // Create a new CNPJ instance
  final cnpj = CNPJ('12345678000190');
  print(cnpj.isValid); // true
  print(cnpj.unmask()); // 12345678000190

  // Use CNPJ static methods
  print(CNPJ.isValidCNPJ('12345678000190')); // true
  print(CNPJ.generateCNPJ()); // 12345678000190
}

Authors 🧑‍💻

About

Dart utils library for specific Brazilian businesses

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published