text_form_field_validator 0.0.3 copy "text_form_field_validator: ^0.0.3" to clipboard
text_form_field_validator: ^0.0.3 copied to clipboard

A super simple dart function for validating text form field in dart and flutter.

example/main.dart

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

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

class MyApp extends StatelessWidget {
  final _formKey = GlobalKey<FormState>();

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Material App',
      home: Scaffold(
        appBar: AppBar(
          title: Text('Material App Bar'),
        ),
        body: Container(
          child: Form(
            key: _formKey,
            child: Column(
              children: [
                TextFormField(
                  validator: (value) => FormValidator.validate(
                    value,
                    required: true,
                    stringFormat: StringFormat.url,
                  ),
                ),
                ElevatedButton(
                  onPressed: () {
                    if (_formKey.currentState!.validate()) {
                      //go to next step
                      print("validation successful");
                    }
                  },
                  child: Text("Submit"),
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}
18
likes
130
pub points
62%
popularity

Publisher

verified publisherniamulhasan.me

A super simple dart function for validating text form field in dart and flutter.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on text_form_field_validator