localregex 2.0.3+1 copy "localregex: ^2.0.3+1" to clipboard
localregex: ^2.0.3+1 copied to clipboard

Regular expressions package for popular patterns in Zimbabwe i.e. Passport Number, Mobile Numbers, Number Plates, etc

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:localregex/localregex.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',
      home: Example(),
    );
  }
}

class Example extends StatefulWidget {
  @override
  _ExampleState createState() => _ExampleState();
}

class _ExampleState extends State<Example> {
  bool _isMobile = false;
  final _formKey = GlobalKey<FormState>();
  final localregex = LocalRegex();
  @override
  Widget build(BuildContext context) {
    return SafeArea(
      child: Scaffold(
        appBar: AppBar(
          title: Text("localregex usage example"),
        ),
        body: Container(
          height: MediaQuery.of(context).size.height * 0.9,
          width: MediaQuery.of(context).size.width,
          color: Colors.white,
          child: Form(
            key: _formKey,
            child: Column(
              children: [
                Padding(
                  padding: const EdgeInsets.all(8.0),
                  child: TextFormField(
                    decoration: InputDecoration(
                      labelText: "Mobile Number",
                    ),
                    // ignore: missing_return
                    validator: (value) {
                      if (!localregex.isZwMobile(value)) {
                        return "Not a valid Zimbabwean mobile number";
                      }
                    },
                  ),
                ),
                Padding(
                  padding: const EdgeInsets.all(8.0),
                  child: Container(
                    color: Theme.of(context).buttonColor,
                    width: MediaQuery.of(context).size.width * 0.9,
                    child: MaterialButton(
                      onPressed: () {
                        if (_formKey.currentState.validate()) {
                          setState(() {
                            _isMobile = true;
                          });
                        } else {
                          setState(() {
                            _isMobile = false;
                          });
                        }
                      },
                      child: Text(
                        "VERIFY",
                        style: TextStyle(
                          fontWeight: FontWeight.bold,
                        ),
                      ),
                    ),
                  ),
                ),
                Padding(
                  padding: const EdgeInsets.all(8.0),
                  child: Text(
                    _isMobile ? "Verified" : "Not verified",
                    style: TextStyle(
                      color: _isMobile ? Colors.green : Colors.red,
                    ),
                  ),
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}
22
likes
150
points
202
downloads

Publisher

verified publisheriamngoni.co.zw

Weekly Downloads

Regular expressions package for popular patterns in Zimbabwe i.e. Passport Number, Mobile Numbers, Number Plates, etc

Homepage

Documentation

API reference

License

Apache-2.0 (license)

Dependencies

flutter

More

Packages that depend on localregex