A Flutter package for password validation, strength checking, and security analysis
This package provides robust password validation with customizable rules, strength scoring, and common password detection.
If you find this package useful, please consider:
- β Starring the repository
- β Buy us a coffee - Support the project
- π Reporting bugs and issues
- π‘ Suggesting new features
- π’ Sharing with your network
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
- β Comprehensive Validation: Length, character types, patterns, and more
- β Strength Scoring: 0-100 score with detailed strength levels
- β Common Password Detection: Built-in dictionary of weak passwords
- β Customizable Rules: Basic, strong, strict, or custom validation rules
- β Pattern Detection: Sequential characters, keyboard patterns, repeated patterns
- β Detailed Results: Validation errors, warnings, and strength analysis
- β Secure Password Generation: Generate cryptographically secure passwords
- β Generation History: Track generated passwords with timestamps
- β Flutter Ready: Works seamlessly with Flutter and Dart applications
- β Zero Dependencies: No external packages required
- β Internationalization: 7 languages supported (EN, ES, FR, DE, PT, IT, FA)
- β Advanced UI Widgets: 6 pre-built Flutter widgets
- β Password History: Similarity detection and reuse prevention
Add this package to your pubspec.yaml
:
dependencies:
password_checker_pro: ^1.0.2
Then run:
flutter pub get
import 'package:password_checker_pro/password_checker_pro.dart';
void main() {
// Create a password checker
final checker = PasswordChecker.strong();
// Validate a password
final result = checker.validate('MySecurePassword123!');
print('Valid: ${result.isValid}');
print('Strength: ${result.strengthDescription}');
print('Score: ${result.strengthScore}/100');
}
Feature | Password Check | Other Packages |
---|---|---|
Dependencies | β Zero | β Multiple |
UI Widgets | β 6 widgets | β Basic only |
Languages | β 7 languages | β English only |
Password History | β Advanced | β Not available |
Test Coverage | β 92.1% | β Limited |
Documentation | β Comprehensive | β Basic |
Performance | β Optimized | β Varies |
import 'package:password_checker_pro/password_checker_pro.dart';
void main() {
// Create a password checker with default rules
final checker = PasswordChecker();
// Validate a password
final result = checker.validate('MySecurePassword123!');
if (result.isValid) {
print('Password is valid!');
print('Strength: ${result.strengthLevel.displayName}');
print('Score: ${result.strengthScore}/100');
} else {
print('Password validation failed:');
for (final error in result.errors) {
print('- $error');
}
}
}
// Basic validation (minimal requirements)
final basicChecker = PasswordChecker.basic();
final basicResult = basicChecker.validate('simple123');
// Strong validation (recommended for most apps)
final strongChecker = PasswordChecker.strong();
final strongResult = strongChecker.validate('MyStrongPassword123!');
// Strict validation (for high-security applications)
final strictChecker = PasswordChecker.strict();
final strictResult = strictChecker.validate('MyVeryStrictPassword123!@#');
// Custom validation rules
final customChecker = PasswordChecker(
rules: ValidationRules(
minLength: 10,
requireUppercase: true,
requireLowercase: true,
requireNumbers: true,
requireSpecialChars: false,
allowSpaces: true,
),
);
final checker = PasswordChecker();
final result = checker.validate('MyPassword123!');
print('Is Valid: ${result.isValid}');
print('Strength Score: ${result.strengthScore}/100');
print('Strength Level: ${result.strengthLevel.displayName}');
// Check individual validation rules
print('Length Check: ${result.checks['minLength']}');
print('Uppercase Check: ${result.checks['uppercase']}');
print('Lowercase Check: ${result.checks['lowercase']}');
print('Numbers Check: ${result.checks['numbers']}');
print('Special Chars Check: ${result.checks['specialChars']}');
// Get warnings
for (final warning in result.warnings) {
print('Warning: $warning');
}
const customRules = ValidationRules(
minLength: 12,
maxLength: 50,
requireUppercase: true,
requireLowercase: true,
requireNumbers: true,
requireSpecialChars: true,
allowSpaces: false,
checkCommonPasswords: true,
checkRepeatedChars: true,
maxRepeatedChars: 2,
checkSequentialChars: true,
maxSequentialLength: 3,
);
final checker = PasswordChecker(rules: customRules);
import 'package:password_checker_pro/password_checker_pro.dart';
void main() {
// Create a password generator with default rules
final generator = PasswordGenerator();
// Generate a single password
final result = generator.generate();
print('Generated password: ${result.password}');
print('Strength: ${result.strengthLevel.displayName}');
print('Score: ${result.strengthScore}/100');
print('Is valid: ${result.isValid}');
// Generate multiple passwords
final results = generator.generateMultiple(5);
for (final result in results) {
print('Password: ${result.password}');
}
// Generate with custom rules
final customGenerator = PasswordGenerator(
rules: const GenerationRules(
length: 20,
includeUppercase: true,
includeLowercase: true,
includeNumbers: true,
includeSpecialChars: true,
avoidSimilarChars: true,
ensureCharacterVariety: true,
),
);
final strongPassword = customGenerator.generate();
print('Strong password: ${strongPassword.password}');
}
// Basic generation (8 chars, lowercase + numbers)
final basicGenerator = PasswordGenerator.basic();
final basicPassword = basicGenerator.generate();
// Strong generation (16 chars, all character types)
final strongGenerator = PasswordGenerator.strong();
final strongPassword = strongGenerator.generate();
// Strict generation (20 chars, all character types, avoid similar chars)
final strictGenerator = PasswordGenerator.strict();
final strictPassword = strictGenerator.generate();
final generator = PasswordGenerator();
// Generate some passwords
generator.generate();
generator.generate();
generator.generate();
// Access generation history
print('Generated ${generator.historyCount} passwords');
print('Last password: ${generator.lastResult?.password}');
// View all generated passwords
for (final result in generator.history) {
print('${result.timestamp}: ${result.password} (${result.strengthLevel.displayName})');
}
// Clear history
generator.clearHistory();
final checker = PasswordChecker.strong();
// Generate password using checker's validation rules
final result = checker.generatePassword(
length: 16,
includeUppercase: true,
includeLowercase: true,
includeNumbers: true,
includeSpecialChars: true,
);
print('Generated: ${result.password}');
print('Valid: ${result.isValid}');
Main class for password validation.
PasswordChecker({ValidationRules? rules})
- Creates with custom rulesPasswordChecker.basic()
- Creates with basic validation rulesPasswordChecker.strong()
- Creates with strong validation rulesPasswordChecker.strict()
- Creates with strict validation rules
PasswordValidationResult validate(String password)
- Validates a password
Result object containing validation information.
bool isValid
- Whether the password passed all validation rulesList<String> errors
- List of validation errorsList<String> warnings
- List of validation warningsint strengthScore
- Password strength score (0-100)PasswordStrengthLevel strengthLevel
- Password strength levelMap<String, bool> checks
- Detailed breakdown of validation checks
Configuration class for password validation rules.
int minLength
- Minimum password length (default: 8)int maxLength
- Maximum password length (default: 128)bool requireUppercase
- Require uppercase letters (default: true)bool requireLowercase
- Require lowercase letters (default: true)bool requireNumbers
- Require numbers (default: true)bool requireSpecialChars
- Require special characters (default: true)bool allowSpaces
- Allow spaces in password (default: false)bool checkCommonPasswords
- Check against common passwords (default: true)bool checkRepeatedChars
- Check for repeated characters (default: true)int maxRepeatedChars
- Maximum repeated characters allowed (default: 3)bool checkSequentialChars
- Check for sequential characters (default: true)int maxSequentialLength
- Maximum sequential length allowed (default: 3)
Enum representing password strength levels:
veryWeak
- Very weak passwordweak
- Weak passwordfair
- Fair passwordgood
- Good passwordstrong
- Strong passwordveryStrong
- Very strong password
Main class for generating secure passwords.
PasswordGenerator({GenerationRules? rules, String? language, CustomMessages? customMessages})
- Creates with custom rulesPasswordGenerator.basic()
- Creates with basic generation rulesPasswordGenerator.strong()
- Creates with strong generation rulesPasswordGenerator.strict()
- Creates with strict generation rulesPasswordGenerator.auto()
- Creates with automatic language detectionPasswordGenerator.localized({required String language})
- Creates with specific language
GenerationResult generate()
- Generates a single passwordList<GenerationResult> generateMultiple(int count)
- Generates multiple passwordsGenerationResult generateValid({ValidationRules? validationRules})
- Generates a password that meets validation rulesvoid clearHistory()
- Clears generation history
List<GenerationResult> history
- List of generated passwordsint historyCount
- Number of generated passwordsGenerationResult? lastResult
- Most recent generation resultString language
- Current language codePasswordMessages messages
- Current messagesGenerationRules rules
- Current generation rules
Configuration class for password generation rules.
int length
- Length of generated password (default: 12)bool includeUppercase
- Include uppercase letters (default: true)bool includeLowercase
- Include lowercase letters (default: true)bool includeNumbers
- Include numbers (default: true)bool includeSpecialChars
- Include special characters (default: true)bool includeSpaces
- Include spaces (default: false)bool avoidSimilarChars
- Avoid similar characters like 0, O, l, 1 (default: true)bool avoidAmbiguousChars
- Avoid ambiguous characters (default: true)String? customChars
- Custom character set to includebool ensureCharacterVariety
- Ensure at least one character from each included set (default: true)
GenerationRules()
- Default rulesGenerationRules.basic()
- Basic rules (8 chars, lowercase + numbers)GenerationRules.strong()
- Strong rules (16 chars, all character types)GenerationRules.strict()
- Strict rules (20 chars, all character types, avoid similar chars)GenerationRules.custom()
- Custom rules with specified parameters
Result of password generation containing the password and metadata.
String password
- The generated passwordGenerationRules rules
- Generation rules usedPasswordValidationResult validation
- Validation result of the generated passwordDateTime timestamp
- When the password was generatedbool isValid
- Whether the password meets validation requirements
class PasswordForm extends StatefulWidget {
@override
_PasswordFormState createState() => _PasswordFormState();
}
class _PasswordFormState extends State<PasswordForm> {
final _passwordController = TextEditingController();
final _checker = PasswordChecker.strong();
PasswordValidationResult? _validationResult;
void _validatePassword(String password) {
setState(() {
_validationResult = _checker.validate(password);
});
}
@override
Widget build(BuildContext context) {
return Column(
children: [
TextField(
controller: _passwordController,
onChanged: _validatePassword,
obscureText: true,
decoration: InputDecoration(
labelText: 'Password',
errorText: _validationResult?.isValid == false
? _validationResult!.errors.first
: null,
),
),
if (_validationResult != null) ...[
LinearProgressIndicator(
value: _validationResult!.strengthScore / 100,
backgroundColor: Colors.grey,
valueColor: AlwaysStoppedAnimation<Color>(
_getStrengthColor(_validationResult!.strengthLevel),
),
),
Text('Strength: ${_validationResult!.strengthLevel.displayName}'),
],
],
);
}
Color _getStrengthColor(PasswordStrengthLevel level) {
switch (level) {
case PasswordStrengthLevel.veryWeak:
case PasswordStrengthLevel.weak:
return Colors.red;
case PasswordStrengthLevel.fair:
return Colors.orange;
case PasswordStrengthLevel.good:
return Colors.yellow;
case PasswordStrengthLevel.strong:
case PasswordStrengthLevel.veryStrong:
return Colors.green;
}
}
}
The package includes powerful pre-built widgets for comprehensive password visualization:
π‘ Pro Tip: All widgets are fully customizable and support animations, theming, and responsive design.
Widget | Purpose | Features |
---|---|---|
PasswordStrengthIndicator | Visual strength display | Animated progress, breakdown, suggestions |
PasswordRequirementsChecklist | Requirements tracking | Interactive checklist, progress bar |
PasswordStrengthMeter | Circular strength meter | Animated progress, customizable size |
PasswordImprovementSuggestions | Smart suggestions | Contextual advice, priority levels |
PasswordVisualizer | Comprehensive view | Tabbed interface, all features |
PasswordHistoryWidget | History management | Similarity detection, reuse prevention |
Animated strength indicator with breakdown visualization and improvement suggestions.
PasswordStrengthIndicator(
result: validationResult,
showBreakdown: true,
showSuggestions: true,
animated: true,
)
Interactive checklist showing password requirements with progress tracking.
PasswordRequirementsChecklist(
result: validationResult,
rules: validationRules,
showProgress: true,
animated: true,
)
Circular strength meter with animated progress and customizable display.
PasswordStrengthMeter(
result: validationResult,
size: 120.0,
animated: true,
showScore: true,
showLevel: true,
)
Smart improvement suggestions with contextual advice and priority levels.
PasswordImprovementSuggestions(
result: validationResult,
rules: validationRules,
showIcons: true,
showPriority: true,
)
Comprehensive visualization widget combining all indicators in a tabbed interface.
PasswordVisualizer(
result: validationResult,
rules: validationRules,
animated: true,
)
flutter pub add password_checker_pro
dependencies:
password_checker_pro:
git:
url: https://github.com/PasswordCheck/Password-Check.git
dependencies:
password_checker_pro:
path: ../path/to/password_checker_pro
We welcome contributions! Please see our Contributing Guide for details.
# Clone the repository
git clone https://github.com/PasswordCheck/Password-Check.git
# Install dependencies
flutter pub get
# Run tests
flutter test
# Run example app
cd example && flutter run
This project is licensed under the MIT License - see the LICENSE file for details.
- Mohsen Kashefi - LinkedIn - mohsenkashefi2000@gmail.com
- Mohammad Amin Rezaei Sepehr - LinkedIn - mohammadaminrez@gmail.com
- π Issues: GitHub Issues
- π¬ Discussions: GitHub Discussions
- π Documentation: Full Documentation