Repository navigation
2.0.0
A rewrite from scratch. Breaking changes are listed under Migration.
Added
- The rules moved to the new dependency-free
password_rulespackage,
re-exported here, so a Dart backend enforces the same policy.
PasswordRulesholds the counts and any furtherPasswordRule, with
validate(password)returning aPasswordValidation(results,
isValid,failed,score,strength),formValidator()for a
TextFormField, andgenerate()for a password that passes every rule. maxLength,CustomRule,CommonPasswordsRuleover the SecLists top-1000
list,MatchRulefor a confirmation field, andPasswordRules.nist()for
NIST SP 800-63B-4. Each rule is aPasswordRulesubclass with its own
test.onChangedwith the full validation,strengthOfto plug an entropy
estimator into the strength label,listenablesto re-check when another
controller changes.barStyle: PasswordBarStyle.continuous, one track that fills with the
score, and a shake whenvalidate()finds the password invalid
(shakeOnInvalid).@Previewwidget previews in the example.FlutterPwValidatorStringsis now an alias ofPasswordRuleStrings;
.persian()is a complete Persian set with Persian digits, andruleMet
andruleNotMetserve screen readers.- Each rule row carries a semantics label, "1 digit, met", so screen readers
announce the state. - Unicode-aware counting: letters and digits from any script count, uppercase
and lowercase use Unicode categories, and a special character is anything
that is not a letter, mark, number or whitespace.minLengthcounts
user-perceived characters, so an emoji sequence counts once. - Animated state changes (
animationDuration, 200 ms by default, zero when
the platform disables animations). - Filled icons by default:
radio_button_uncheckedbefore any text,
check_circlefor a passing rule,cancelfor a failing one, each
replaceable throughneutralIcon,successIconandfailureIcon. showStrengthLabelshows Weak, Fair, Good or Strong above the bar; the
level is also available asPasswordValidation.strength.itemBuilderandbarBuilderto draw the rows or the bar yourself.textStyle,padding,spacing,barThickness,showBarandshowList
parameters.- Colors default to the app theme:
colorScheme.outlinebefore any text,
colorScheme.errorfor a failing rule,bodyMediumfor the labels. FlutterPwValidatorStringstakes one function per rule and one for the
strength levels, so a translation can handle plurals and digit shapes.- Widget tests,
flutter_lints, a GitHub Actions workflow and pub.dev
screenshots.
Fixed
- The controller listener is removed when the widget is disposed.
- Changing
strings,rulesorcontrolleron a mounted widget is applied
(issue 30). - A pre-filled controller is evaluated on first build instead of after the
first keystroke.
Migration from 1.x
minLength,normalCharCount,uppercaseCharCount,lowercaseCharCount,
numericCharCountandspecialCharCountmoved into
rules: PasswordRules(minLength:, letters:, uppercase:, lowercase:, digits:, special:).widthandheightare gone; the widget fills the available width and
sizes its own height. Wrap it in aSizedBoxto constrain it.onSuccessis optional.- A translation is
FlutterPwValidatorStrings(uppercase: (count) => '...')
instead of a subclass with"- Uppercase letter"fields. - Package files moved under
lib/src/; import only
package:flutter_pw_validator/flutter_pw_validator.dart. - Requires Dart 3.8 and Flutter 3.32 or newer.