password_check 2.1.0 copy "password_check: ^2.1.0" to clipboard
password_check: ^2.1.0 copied to clipboard

A customizable and accessible Flutter checklist for real-time password validation.

password_check #

Português · English

pub package CI License: MIT

Widget Flutter para exibir, validar e personalizar requisitos de senha em tempo real, com suporte a acessibilidade e sem dependências externas.

Flutter widget for displaying, validating, and customizing password requirements in real time, with accessibility support and no external dependencies.

Demonstração 1

Demonstração 2

Português #

Sobre #

O password_check fornece o widget PasswordChecklist, que acompanha um TextEditingController e mostra quais regras da senha foram atendidas. Ele inclui regras configuráveis, mensagens personalizadas, ordenação, builders de ícone e item, estilos e semântica acessível.

A linha 2.x preserva a API pública existente. A versão 2.1.0 requer Flutter 3.41 ou superior e Dart 3.11 ou superior.

Instalação #

flutter pub add password_check

Ou adicione ao pubspec.yaml:

dependencies:
  password_check: ^2.1.0

Uso básico #

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

final controller = TextEditingController();

PasswordChecklist(
  controller: controller,
  minCharacters: 8,
  onValidationChanged: (isValid) {
    setState(() => _isPasswordValid = isValid);
  },
)

onValidationChanged é chamado uma vez na montagem com a validade inicial. Depois disso, o callback só é emitido quando a validade global muda, embora as regras visuais continuem sendo atualizadas a cada edição. Trocas do controller ou da configuração também recalculam o estado.

Customização #

PasswordChecklist(
  controller: controller,
  onValidationChanged: (_) {},
  checkOnlyNumbers: true,
  specialCharactersRegex: RegExp(r'[!@#\$%&*]'),
  validColor: Colors.teal.shade800,
  invalidColor: Colors.deepOrange.shade900,
  ruleOrder: const [
    PasswordRuleType.uppercase,
    PasswordRuleType.lowercase,
    PasswordRuleType.number,
    PasswordRuleType.minCharacters,
    PasswordRuleType.specialCharacter,
    PasswordRuleType.notOnlyNumbers,
  ],
  customIconBuilder: (ruleId, isValid) => Icon(
    isValid ? Icons.check_circle : Icons.cancel,
  ),
)

Os defaults visuais da linha 2.x são independentes do ThemeData: regras válidas usam verde e negrito; regras inválidas usam vermelho e texto normal. Forneça cores e estilos explícitos para garantir contraste com o fundo do seu aplicativo.

Acessibilidade #

No layout padrão, indicador e mensagem formam um único nó semântico com estado marcado/desmarcado. O texto permite quebra de linha e escala 2.0 em viewports estreitos. Ao usar itemBuilder, o consumidor assume a responsabilidade pela semântica do conteúdo substituído.

Desenvolvimento #

flutter pub get
flutter analyze
flutter test

Contribuições são bem-vindas por issues e pull requests no repositório do projeto.

English #

About #

password_check provides the PasswordChecklist widget, which listens to a TextEditingController and displays which password requirements are met. It supports configurable rules, custom messages, ordering, icon and item builders, styles, and accessible semantics.

The 2.x line preserves the existing public API. Version 2.1.0 requires Flutter 3.41 or newer and Dart 3.11 or newer.

Installation #

flutter pub add password_check

Or add it to your pubspec.yaml:

dependencies:
  password_check: ^2.1.0

Basic usage #

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

final controller = TextEditingController();

PasswordChecklist(
  controller: controller,
  minCharacters: 8,
  onValidationChanged: (isValid) {
    setState(() => _isPasswordValid = isValid);
  },
)

onValidationChanged is called once on mount with the initial validity. After that, it is emitted only when global validity changes, while individual visual rules continue to update on every edit. Controller and configuration changes also trigger recalculation.

Customization #

PasswordChecklist(
  controller: controller,
  onValidationChanged: (_) {},
  checkOnlyNumbers: true,
  specialCharactersRegex: RegExp(r'[!@#\$%&*]'),
  validColor: Colors.teal.shade800,
  invalidColor: Colors.deepOrange.shade900,
  ruleOrder: const [
    PasswordRuleType.uppercase,
    PasswordRuleType.lowercase,
    PasswordRuleType.number,
    PasswordRuleType.minCharacters,
    PasswordRuleType.specialCharacter,
    PasswordRuleType.notOnlyNumbers,
  ],
  customIconBuilder: (ruleId, isValid) => Icon(
    isValid ? Icons.check_circle : Icons.cancel,
  ),
)

The 2.x visual defaults are independent of ThemeData: valid rules use green and bold text; invalid rules use red and regular text. Provide explicit colors and styles to guarantee contrast against your application's background.

Accessibility #

In the default layout, the indicator and message are merged into a single semantic node with checked/unchecked state. Text supports wrapping and 2.0 text scaling on narrow viewports. When using itemBuilder, the consumer is responsible for the semantics of the replacement content.

Development #

flutter pub get
flutter analyze
flutter test

Contributions are welcome through issues and pull requests in the project repository.

API / Referência #

Parâmetro / Parameter Tipo / Type Padrão / Default Desde / Since
controller TextEditingController obrigatório / required 1.0.0
onValidationChanged ValueChanged<bool> obrigatório / required 1.0.0
checkEightCharacters bool true 1.0.0
checkSpecialCharacter bool true 1.0.0
checkNumber bool true 1.0.0
checkUppercase bool true 1.0.0
checkLowercase bool true 1.0.0
checkOnlyNumbers bool false 2.0.0
minCharacters int 8 1.0.0
specialCharactersRegex RegExp? padrão interno / internal default 2.0.0
validColor Color? Colors.green 1.0.0
invalidColor Color? Colors.red 1.0.0
eightCharactersMessage String? pt-BR 1.0.0
specialCharacterMessage String? pt-BR 1.0.0
numberMessage String? pt-BR 1.0.0
uppercaseMessage String? pt-BR 1.0.0
lowercaseMessage String? pt-BR 1.0.0
onlyNumbersMessage String? pt-BR 2.0.0
customIcon Widget? null 1.0.0
customIconBuilder Widget? Function(String, bool)? null 2.0.0
itemSpacing double 8.0 2.0.0
validTextStyle TextStyle? null 2.0.0
invalidTextStyle TextStyle? null 2.0.0
itemBuilder Widget? Function(PasswordRuleItem)? null 2.0.0
padding EdgeInsetsGeometry? null 2.0.0
margin EdgeInsetsGeometry? null 2.0.0
crossAxisAlignment CrossAxisAlignment start 2.0.0
mainAxisAlignment MainAxisAlignment start 2.0.0
ruleOrder List<PasswordRuleType>? null 2.0.0

Consulte a referência de API no pub.dev para a documentação gerada.

Licença / License #

MIT — consulte / see LICENSE.

5
likes
150
points
84
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A customizable and accessible Flutter checklist for real-time password validation.

Homepage
Repository (GitHub)
View/report issues

Topics

#password #validation #form #widget #accessibility

License

unknown (license)

Dependencies

flutter

More

Packages that depend on password_check