text_field_validator 0.0.9 copy "text_field_validator: ^0.0.9" to clipboard
text_field_validator: ^0.0.9 copied to clipboard

A flutter package for both Android and iOS which provides the validation functionalities for the input fields.

example/lib/main.dart

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

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

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Text Field Validator Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Validator Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),
      body: Container(
        padding: const EdgeInsets.symmetric(horizontal: 16),
        child: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              TextFormField(
                validator: (value) {
                  return TextFieldValidator.textValidator(
                    value: value,
                    minLength: 2,
                    maxLength: 5,
                  );
                },
                autovalidateMode: AutovalidateMode.onUserInteraction,
              ),
              const SizedBox(height: 20),
              TextFormField(
                validator: (value) {
                  return TextFieldValidator.passWordValidator(
                    password: value,
                    minPasswordLength: 8,
                  );
                },
                autovalidateMode: AutovalidateMode.onUserInteraction,
              ),
              TextFormField(
                validator: (value) {
                  return TextFieldValidator.urlValidator(
                    url: value,
                  );
                },
                keyboardType: TextInputType.url,
                autovalidateMode: AutovalidateMode.onUserInteraction,
              ),
            ],
          ),
        ),
      ),
    );
  }
}
0
likes
150
points
55
downloads

Publisher

unverified uploader

Weekly Downloads

A flutter package for both Android and iOS which provides the validation functionalities for the input fields.

Repository (GitHub)

Documentation

API reference

License

BSL-1.0 (license)

Dependencies

flutter

More

Packages that depend on text_field_validator