Form Validation Package

A Flutter package that provides beautiful and customizable form validation widgets with built-in validation rules. This package simplifies form validation in Flutter applications by providing pre-built validators and a customizable text field widget.

pub package

Features

Beautiful Form Fields

  • Pre-styled text fields with modern design
  • Customizable appearance
  • Floating labels
  • Error message styling

🔍 Built-in Validators

  • Required field validation
  • Email validation
  • Phone number validation
  • Password complexity validation
  • Minimum length validation
  • Combinable validators

🎨 Customization

  • Custom error messages
  • Custom validation rules
  • Flexible styling options

Screenshots

Password Validation

Password Validation

Form Input States

Form States

Save Password Dialog

Save Dialog

Getting Started

Installation

Add this to your package's pubspec.yaml file:

dependencies:
  validation_package: ^0.0.1

Then run:

flutter pub get

Basic Usage

import 'package:validation_package/validation_package.dart';

// Simple required field
ValidatedTextField(
  label: 'Username',
  controller: _usernameController,
  validator: Validators.required(),
);

// Email validation
ValidatedTextField(
  label: 'Email',
  controller: _emailController,
  validator: Validators.email(),
);

// Password with multiple validations
ValidatedTextField(
  label: 'Password',
  controller: _passwordController,
  obscureText: true,
  validator: Validators.combine([
    Validators.required(),
    Validators.minLength(6),
    Validators.passwordComplexity(),
  ]),
);

Available Validators

Required Field

Validators.required(message: 'Custom error message')

Email

Validators.email(message: 'Please enter a valid email')

Minimum Length

Validators.minLength(8, message: 'Must be at least 8 characters')

Phone Number

Validators.phone(message: 'Enter a valid phone number')

Password Complexity

Validators.passwordComplexity(
  message: 'Password must contain both letters and numbers'
)

Combining Validators

Validators.combine([
  Validators.required(),
  Validators.minLength(6),
  Validators.passwordComplexity(),
])

Customizing TextField

ValidatedTextField(
  label: 'Custom Field',
  controller: _controller,
  validator: Validators.required(),
  obscureText: false, // For password fields
);

Contributing

We welcome contributions! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Libraries

validation_package