cnpj_cpf_formatter 1.0.8 cnpj_cpf_formatter: ^1.0.8 copied to clipboard
This library gives you a formatter to CNPJ or CPF documents. Enjoy it!
example/cnpj_cpf_formatter_example.dart
import 'package:flutter/material.dart';
import 'package:cnpj_cpf_formatter/cnpj_cpf_formatter.dart';
void main() => runApp(App());
class App extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: HomePage(),
);
}
}
class HomePage extends StatefulWidget {
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Padding(
padding: const EdgeInsets.all(8),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
TextField(
decoration: InputDecoration(
labelText: 'CPF',
helperText: 'just CPF formatting',
),
inputFormatters: [
CnpjCpfFormatter(
eDocumentType: EDocumentType.CPF,
)
],
),
SizedBox(
height: 16,
),
TextField(
decoration: InputDecoration(
labelText: 'CNPJ',
helperText: 'just CNPJ formatting',
),
inputFormatters: [
CnpjCpfFormatter(
eDocumentType: EDocumentType.CNPJ,
)
],
),
SizedBox(
height: 16,
),
TextField(
decoration: InputDecoration(
labelText: 'CNPJ/CPF',
helperText: 'CNPJ and CPF formatting',
),
inputFormatters: [
CnpjCpfFormatter(
eDocumentType: EDocumentType.BOTH,
)
],
)
],
),
),
);
}
}