flutter password validator
flutter password validator package helps you to validate user-entered passwords in your flutter app.
flutter password validator package helps you to validate sign-in user-entered passwords with your rules.
how to use
1- depend on it
add it to your package’s pubspec.yaml file:
dependencies:
flutter_pw_validator: ^1.2.1
2- install it
install packages from the command line:
flutter pub get
3- usage
first you have to import the file:
import 'package:flutter_pw_validator/flutter_pw_validator.dart';
and then just put it right under your password textfield and pass the controller to that:
new textfield(
controller: _passwordcontroller
),
new flutterpwvalidator(
controller: _passwordcontroller,
minlength: 6,
uppercasecharcount: 2,
numericcharcount: 3,
specialcharcount: 1,
width: 400,
height: 150,
onsuccess: yourcallbackfunction
)
properties
property | description | default value | required |
---|---|---|---|
controller | takes your password textfield controller | null | yes |
minlength | takes total minimum length of password | null | yes |
uppercasecharcount | takes minimum uppercase character count that has to include in the password | 0 | no |
numericcharcount | takes minimum numeric character count that has to include in the password | 0 | no |
specialcharcount | takes minimum special character count that has to include in the password | 0 | no |
width | takes the widget width | null | yes |
height | takes the widget height | null | yes |
onsuccess | takes a void callback function that runs when the password is matched with condition(s) | null | yes |
defaultcolor | takes default state color of the widget | color(0xffd3d3d3) | no |
successcolor | takes success state color of the widget | color(0xff2ee292) | no |
failurecolor | takes failure state color of the widget | color(0xfff9433e) | no |
Comments are closed.