Flutter Password Validator package helps you to validate user-entered passwords in your flutter app.

Overview

Flutter Password Validator

License Pub Version GitHub stars


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

Example Project

You can use this example project to see how it works.

Comments
  • setState() called after dispose()

    setState() called after dispose()

    I have made use of the widget in a form field when a user is registering for a new account like so

    class PasswordValidator extends StatelessWidget {
      final TextEditingController controller;
      final Function() onSuccess;
      const PasswordValidator({
        Key? key,
        required this.controller,
        required this.onSuccess,
      }) : super(key: key);
    
      @override
      Widget build(BuildContext context) {
        return Padding(
          padding: const EdgeInsets.only(
            left: 20.0,
            top: 0.0,
            right: 20.0,
            bottom: 20.0,
          ),
          child: FlutterPwValidator(
            width: MediaQuery.of(context).size.width,
            height: MediaQuery.of(context).size.height * 0.2,
            minLength: 6,
            specialCharCount: 1,
            uppercaseCharCount: 1,
            numericCharCount: 1,
            onSuccess: onSuccess,
            controller: controller,
          ),
        );
      }
    }
    

    During the API call, I set the page to be replaced with a ProgressIndicator. When the API calls fails, the user is kept on the same page and the ProgressIndicator is removed and text form fields are reset, in resetting the controller value that the password field is bound to, the following error is thrown

    The following assertion was thrown while dispatching notifications for TextEditingController:
    setState() called after dispose(): _FlutterPwValidatorState#85b38(lifecycle state: defunct, not mounted)
    
    This error happens if you call setState() on a State object for a widget that no longer appears in the widget tree (e.g., whose parent widget no longer includes the widget in its build). This error can occur when code calls setState() from a timer or an animation callback.
    

    The above error is also thrown anytime the password field is tapped or interacted with at all.

    opened by lbk9 6
  • Implemented validation for simple letters count

    Implemented validation for simple letters count

    I needed a simple validation of the number of letters the component did not have this functionality.

    I implemented it if you think it's interesting to keep in the project follow the PR.

    opened by jeffersonmello 4
  • setState() called after dispose()

    setState() called after dispose()

    I have implemented the PW Validator and I am getting this error with every letter typed into the password field

    ======== Exception caught by foundation library ==================================================== The following assertion was thrown while dispatching notifications for TextEditingController: setState() called after dispose(): _FlutterPwValidatorState#095a5(lifecycle state: defunct, not mounted)

    This error happens if you call setState() on a State object for a widget that no longer appears in the widget tree (e.g., whose parent widget no longer includes the widget in its build). This error can occur when code calls setState() from a timer or an animation callback.

    opened by ramluro1 4
  • we need key attribute, because i want to access the object functions like validate function from my Register button

    we need key attribute, because i want to access the object functions like validate function from my Register button

    I tried so hard to add a key attribute to your code, but it didn't work out I want a key attribute so I can access the validate function when I press my register button, so it won't be greyed out when I press register if he didn't type a password correctly

    opened by MazenxELGayar 2
  • Add i18n

    Add i18n

    Hi there,

    I added the possiblity to give our own FlutterPwValidatorStrings as discussed in https://github.com/ArefMozafari/flutter_pw_validator/issues/9

    Tell me if I need to change a few things. Thanks!

    enhancement 
    opened by HugoHeneault 2
  • Hacktoberfest

    Hacktoberfest

    Hi there,

    As every year in october, Hacktoberfest has started! :-) More details here : https://hacktoberfest.digitalocean.com/resources/maintainers Would you add the hacktoberfest label to your repo so contributors know they can participate and fix issues/craft PRs?

    Thanks a lot.

    opened by HugoHeneault 1
  • Add i18n

    Add i18n

    Hey there!

    It would be awesome if we could provide translation for hints. I can craft a PR, is this OK for you?

    I was thinking of renaming the Strings Class by a FlutterPwValidatorStrings and allowing to optionaly pass it to the FlutterPwValidator widget with a strings params. If not provided, use the default one.

    Thanks alot!

    enhancement Hacktoberfest 
    opened by HugoHeneault 1
  • Fix pub.dev issues link

    Fix pub.dev issues link

    Hey there. Thanks for this cool pub ! :-)

    On your pub.dev page, the issue link is broken. I fixed it, you'll need to republish for changes to be applied.

    opened by HugoHeneault 1
  • Why are Width and Height Required?

    Why are Width and Height Required?

    Why are width and height required? For a project I am working on it would be way more comfortable if the width and height would be automatically adjusted to the available space. Parameters like the height of the Validationbar, Paddings, TextSize etc could be passed in from the outside but have a sensible default.

    Would you be open if I will open up a PR soon removing the fixed width and height?

    enhancement Hacktoberfest 
    opened by ABausG 1
  • Improving Documentation Score

    Improving Documentation Score

    Description: The documnentation score of the package is 10/20 which can be improved by using documentation comments instead of normal comments

    Screenshot: image

    - Normal Comment: //
    - Documentation Comment: ///
    
    opened by adithyaakrishna 1
  • Don't dispose controller owned by someone else

    Don't dispose controller owned by someone else

    Disposing the TextEditingController should be done by the one who created the controller.

    If it is disposed in the place where it was created it will lead to the following Error instead:

    The following assertion was thrown while finalizing the widget tree:
    A TextEditingController was used after being disposed.
    
    Once you have called dispose() on a TextEditingController, it can no longer be used.
    When the exception was thrown, this was the stack: 
    

    Moreover it might be that the TextEditingController is still needed even after the FlutterPWValidator is no longer needed

    opened by ABausG 0
  • Can we show the password validator only when text field is on focus ?

    Can we show the password validator only when text field is on focus ?

    image

    Sharing an example where I have both Email and password and for a better user experience, I want to be able to show a password validator only when someone starts to type the password.

    Moreover, is there a way to shift the validator to align perfectly under the field ?

    opened by dgurudot 1
  • Anyway to enforce the same rules when someone forget password and changes it ?

    Anyway to enforce the same rules when someone forget password and changes it ?

    It's good and super cool to be able to use the password validator at signup or while changing it from UI. However, I am wondering if there is a similar way I could enforce rules while resetting passwords coming from Firebase.

    opened by dgurudot 1
Owner
Aref Mozafari
Mobile Developer at Xeniac Development Team
Aref Mozafari
A Flutter OAuth package for performing user authentication for your apps.

Flutter OAuth A Flutter OAuth package for performing user authentication for your apps. I've tested this with a small collection of APIs (Buffer, Stra

Joe Birch 173 Dec 9, 2022
Flutter implementation of the Quickstart Supabase User Management app.

Supabase Flutter User Management This repo is a quick sample of how you can get started building apps using Flutter and Supabase. You can find a step

Supabase Community 56 Nov 14, 2022
A Flutter package that implements Google Sign In in pure Dart.

A Flutter package that implements Google Sign In in pure Dart. This package is compatible with google_sign_in plugin and works on all platforms Flutter supports but it's intended to be mainly used on Desktop.

Razvan Lung 10 Oct 26, 2022
By using Flutter Local Auth users can authenticate with Fingerprint & Touch ID in Flutter.

Flutter Tutorial - Fingerprint & Touch ID - Local Auth By using Flutter Local Auth users can authenticate with Fingerprint & Touch ID in Flutter. Soci

Johannes Milke 37 Dec 15, 2022
A Flutter plugin for allowing users to authenticate with native Android & iOS Facebook login SDKs.

flutter_facebook_login A Flutter plugin for using the native Facebook Login SDKs on Android and iOS. AndroidX support if you want to avoid AndroidX, u

Iiro Krankka 404 Nov 26, 2022
Flutter Plugin for Sign In with Apple

Apple Sign In - Flutter Plugin Access Sign In with Apple from Flutter. Platform support This plugin currently only supports iOS. There's a JavaScript

Tom Gilder 156 Dec 28, 2022
The Simplest way to Authenticate in Flutter

Most apps need to make API calls. Every API needs authentication, yet no developer wants to deal with authentication. Simple Auth embeds authenticatio

James Clancey 340 Dec 25, 2022
A Flutter wrapper for AppAuth iOS and Android SDKs

flutter_appauth A Flutter plugin that provides a wrapper for native AppAuth SDKs (https://appauth.io) used authenticating and authorizing users. The r

Michael Bui 230 Dec 21, 2022
An OAuth authentication system built in Flutter using Google OAuth.

An OAuth authentication system built in Flutter using Google OAuth.

Kaushal 0 Sep 20, 2021
This project is an example of Firebase authentication in a flutter

This project is an example of Firebase authentication in a flutter. This project shows how to implement a full authentication flow in Flutter, using sign Up with email and password, sign in with email and password, and reset password.

Nittin 4 Mar 11, 2022
WebView OAuth flows for desktop flutter apps

desktop_webview_auth A new flutter plugin project. Getting Started This project is a starting point for a Flutter plug-in package, a specialized packa

Invertase 22 Dec 17, 2022
Easy third party authentication (OAuth 2.0) for Flutter apps.

visa This is an OAuth 2.0 package that makes it super easy to add third party authentication to flutter apps. It has support for FB, Google, LinkedIn,

Emmanuel Olaojo 135 Dec 23, 2022
Authentication pages I made with Flutter and Firebase

Auth-with-Flutter-and-Firebase Authentication pages I made with Flutter and Firebase Overview This email and password authentication is implemented wi

Said Mirzayev 3 Jul 24, 2022
An example of JWT authentication with flutter.

flutter-jwt-auth-template An example of JWT authentication with flutter. Getting Started Clone this repository, and inside its folder, run: flutter pu

Enzo Di Tizio 23 Jan 4, 2023
In this Application Built Using Flutter🎯 along with FireBase 🔥for Managing the data

In this Application Built Using Flutter?? along with FireBase ??for Managing the data, I have Curated a simple?? Login/Sign Up Space along with Authentication!

Aashvi Kothari 4 Oct 9, 2022
Generate secure passwords, check for exposed passwords, get visual feedback for password strength or get form validation with a minimum password strength required.

password_strength_checker Generate secure passwords, check for exposed passwords, get visual feedback for password strength or get form validation wit

Dario Varriale 6 Aug 8, 2023
Generic validator - A generic validator with business logic separation in mind

This package provides APIs to facilitate separating validation and business rule

Ahmed Aboelyazeed 5 Jan 3, 2023
A package that lets you include a cool, nice looking and validated Password TextFormField in your app to enhance user experience. The package is fully & easily modifiable.

A package that lets you include a cool, nice looking and validated Password TextFormField in your app to enhance user experience. The package is fully

Muhammad Hamza 21 Jan 1, 2023
A package that lets you include a cool, nice looking and validated Password TextFormField in your app to enhance user experience. The package is fully & easily modifiable.

A package that lets you include a cool, nice looking and validated Password TextFormField in your app to enhance user experience. The package is fully

Muhammad Hamza 20 Jun 7, 2022
Flutter textfield validation lets you validate different textform fields in your Flutter app

Flutter textfield validation lets you validate different textform fields in your Flutter app

World-Package 2 Sep 15, 2022