搜索插件、代码仓与 APP 分类

flutter_pw_validator 封面
插件详情v2.0.0

flutter_pw_validator

Flutter Pw Validator 包帮助您根据您的规则验证用户登录时输入的密码。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
2780
喜欢数
176
Pub 分数
160

安装插件

flutter pub add flutter_pw_validator

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

Flutter Pw Validator 是一个轻量级包,旨在根据可自定义的规则验证用户输入的密码。它有助于确保密码强度并符合特定标准,例如最小长度、包含特殊字符或数字要求。非常适合用于身份验证流程,可无缝集成到多个平台的登录表单中。该包支持 Android、iOS、Web、macOS、Windows 和 Linux,使其适用于跨平台应用。通过简单的 API,开发者可以轻松实施安全的密码策略,而无需编写复杂的验证逻辑。

适合场景

  • 用户注册表单
  • 密码强度检查
  • 安全登录流程
  • 身份验证表单验证
  • 符合安全策略

主要特点

  • 可自定义的验证规则
  • 跨平台支持
  • 简单集成
  • 实时反馈
  • 轻便且快速

适合对象

  • 开发安全认证系统的开发者
  • 需要强密码策略的应用程序
  • 跨平台 Flutter 应用
  • 移动和Web应用程序中的表单验证
  • 重视用户安全的团队

使用建议

  • 需要手动配置规则
  • 无内置 UI 组件
  • 取决于开发人员定义的标准
  • 仅限密码验证
  • 不适合复杂的凭据管理

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

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: <latest>
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,
    lowercaseCharCount: 2,
    numericCharCount: 3,
    specialCharCount: 1,
    width: 400,
    height: 150,
    onSuccess: yourCallbackFunction,
    onFail: 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
lowercaseCharCount Takes minimum lowercase 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 A void callback function that runs when the password is matched with the condition(s) null Yes
onFail A void callback that gets called everytime the password doesn't match with the condition(s) null No
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
strings A class implementing the default FlutterPwValidatorStrings English FlutterPwValidatorStrings No
key Key to access the widget state and its functions GlobalKey<FlutterPwValidatorState>() null No

i18n

If you want to translate this plugin simply implements the FlutterPwValidatorStrings class and pass it to the widget.

class FrenchStrings implements FlutterPwValidatorStrings {
  @override
  final String atLeast = 'Au moins - caractères';
  @override
  final String uppercaseLetters = '- Lettres majuscules';
  @override
  final String numericCharacters = '- Chiffres';
  @override
  final String specialCharacters = '- Caractères spéciaux';
}

FlutterPwValidator(
    // ...
    // your config above
    strings: FrenchStrings()
)

Example Project

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

所属分类

依赖

依赖清单 1 项

  • password_rules^1.0.0

源码仓库

使用此插件的项目