queen_validators 0.0.1+2-beta copy "queen_validators: ^0.0.1+2-beta" to clipboard
queen_validators: ^0.0.1+2-beta copied to clipboard

outdated

validate variables , forms and DTO s validation + extensions methods

example/lib/main.dart

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

void main() => runApp(MaterialApp(
      title: 'Queen Validators 👑',
      debugShowCheckedModeBanner: false,
      home: HomePage(),
    ));

class HomePage extends StatelessWidget {
  final _formKey = GlobalKey<FormState>();
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('Queen Validators 👑'), centerTitle: true),
      body: Center(
        child: Form(
          key: _formKey,
          child: Card(
            child: Container(
              padding: EdgeInsets.symmetric(
                horizontal: MediaQuery.of(context).size.width * 0.05,
              ),
              width: MediaQuery.of(context).size.width * 0.90,
              height: MediaQuery.of(context).size.height * 0.25,
              child: Column(
                mainAxisAlignment: MainAxisAlignment.spaceAround,
                children: [
                  Text('login with email and password'),
                  TextFormField(
                    decoration: InputDecoration(labelText: 'email'),
                    validator: qValidator([
                      IsEmail(),
                      MaxLength(50),
                    ]),
                  ),
                  TextFormField(
                    obscureText: true,
                    decoration: InputDecoration(labelText: 'password'),
                    validator: qValidator([
                      IsNotEmpty(msg: 'required'),
                      MinLength(16, msg: 'password is to short'),
                      MaxLength(50),
                    ]),
                  ),
                  MaterialButton(
                    color: Colors.blue,
                    child: Text('validate the form '),
                    onPressed: () {
                      try {
                        bool x = _formKey.currentState.validate();
                        if (x) {
                          Scaffold.of(context)
                              .showSnackBar(SnackBar(content: Text('pass')));
                        }
                        Scaffold.of(context)
                            .showSnackBar(SnackBar(content: Text('fails')));
                      } catch (e) {
                        Scaffold.of(context).showSnackBar(
                            SnackBar(content: Text(e.toString())));
                      }
                    },
                  ),
                ],
              ),
            ),
          ),
        ),
      ),
    );
  }
}
80
likes
0
pub points
87%
popularity

Publisher

verified publishermaxzod.com

validate variables , forms and DTO s validation + extensions methods

Repository (GitHub)
View/report issues

License

unknown (license)

More

Packages that depend on queen_validators