easy_mask 2.0.1 icon indicating copy to clipboard operation
easy_mask: ^2.0.1 copied to clipboard

Easy and Powerful Mask for TextField, TextFormField and Strings. Has multi mask support, reverse mask for currency and placeholder. It controls user's cursor.

example/lib/main.dart

import 'package:easy_mask/easy_mask.dart';
import 'package:flutter/material.dart';

// import 'package:easy_mask.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Container(
              padding: EdgeInsets.symmetric(horizontal: 60),
              child: TextField(
                decoration: InputDecoration(hintText: 'Cellphone'),
                inputFormatters: [
                  TextInputMask(mask: '\\+ 9 (999) 9999 99 99', reverse: false)
                ],
              ),
            ),
            Container(
              padding: EdgeInsets.symmetric(horizontal: 60),
              child: TextField(
                decoration: InputDecoration(hintText: 'Brazilian CPF'),
                inputFormatters: [
                  TextInputMask(
                      mask: '999.999.999-99',
                      placeholder: '_',
                      maxPlaceHolders: 11,
                      reverse: false)
                ],
              ),
            ),
            Container(
              padding: EdgeInsets.symmetric(horizontal: 60),
              child: TextField(
                decoration: InputDecoration(hintText: 'Multi Mask CPF/CNPJ'),
                inputFormatters: [
                  TextInputMask(
                      mask: ['999.999.999-99', '99.999.999/9999-99'],
                      reverse: false)
                ],
              ),
            ),
            Container(
              padding: EdgeInsets.symmetric(horizontal: 60),
              child: TextField(
                decoration: InputDecoration(hintText: 'Multi Mask Phone'),
                inputFormatters: [
                  TextInputMask(
                      mask: ['(99) 9999 9999', '(99) 99999 9999'],
                      reverse: false)
                ],
              ),
            ),
            Container(
              padding: EdgeInsets.symmetric(horizontal: 60),
              child: TextField(
                decoration: InputDecoration(hintText: 'Date'),
                inputFormatters: [
                  TextInputMask(mask: '99/99/9999', reverse: false)
                ],
              ),
            ),
            Container(
              padding: EdgeInsets.symmetric(horizontal: 60),
              child: TextField(
                decoration: InputDecoration(hintText: 'Brazilian Phone'),
                inputFormatters: [
                  TextInputMask(mask: '\\+5!5! (!99) 99999-9999')
                ],
              ),
            ),
            Container(
              padding: EdgeInsets.symmetric(horizontal: 120),
              child: TextField(
                textAlign: TextAlign.right,
                decoration: InputDecoration(hintText: 'Money'),
                inputFormatters: [
                  TextInputMask(
                    mask: '\$! !9+,99',
                    placeholder: '0',
                    maxPlaceHolders: 3,
                    reverse: true,
                  )
                ],
              ),
            )
          ],
        ),
      ),
    );
  }
}
138
likes
130
pub points
96%
popularity

Publisher

unverified uploader

Easy and Powerful Mask for TextField, TextFormField and Strings. Has multi mask support, reverse mask for currency and placeholder. It controls user's cursor.

Repository (GitHub)

Documentation

API reference

License

Icon for licenses.Apache-2.0 (LICENSE)

Dependencies

flutter

More

Packages that depend on easy_mask