mask_text_input_formatter 1.0.1 copy "mask_text_input_formatter: ^1.0.1" to clipboard
mask_text_input_formatter: ^1.0.1 copied to clipboard

outdated

Masked text input formatter for flutter text fields

example/lib/main.dart

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

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'MaskTextInputFormatterExample',
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: ExamplePage(title: 'ExamplePage'),
    );
  }
}

class ExamplePage extends StatefulWidget {
  final String title;

  ExamplePage({Key key, this.title}) : super(key: key);

  @override
  _ExamplePageState createState() => _ExamplePageState();
}

class _ExamplePageState extends State<ExamplePage> {

  var textEditingController = TextEditingController();
  var maskTextInputFormatter = MaskTextInputFormatter(mask: "+# (###) ###-##-##", filter: { "#": RegExp(r'[0-9]') });

  @override
  Widget build(BuildContext context) {
    return Scaffold(backgroundColor: Colors.blueAccent, body:
      SafeArea(child:
        Padding(padding: const EdgeInsets.all(16.0), child:
          TextField(controller: textEditingController, inputFormatters: [maskTextInputFormatter], autocorrect: false, keyboardType: TextInputType.phone, decoration:
            InputDecoration(hintText: "+1 (123) 123-45-67", fillColor: Colors.white, filled: true)
          )
        )
      )
    );
  }
}
1.23k
likes
0
points
473k
downloads

Publisher

unverified uploader

Weekly Downloads

Masked text input formatter for flutter text fields

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on mask_text_input_formatter