feat: add password requirement display and enhance password validation on the signup page.
All checks were successful
Deploy Flutter to Firebase (Mac) / deploy-android (push) Successful in 2m40s

This commit is contained in:
Van Leemput Dayron
2025-12-15 16:02:50 +01:00
parent ca3f62c709
commit 63fc18ea74
3 changed files with 73 additions and 1 deletions

View File

@@ -0,0 +1,57 @@
import 'package:flutter/material.dart';
class PasswordRequirements extends StatelessWidget {
final String password;
const PasswordRequirements({super.key, required this.password});
bool get _hasMinLength => password.length >= 8;
bool get _hasUppercase => password.contains(RegExp(r'[A-Z]'));
bool get _hasLowercase => password.contains(RegExp(r'[a-z]'));
bool get _hasDigit => password.contains(RegExp(r'[0-9]'));
bool get _hasSpecialChar =>
password.contains(RegExp(r'[!@#\$%^&*(),.?":{}|<>]'));
@override
Widget build(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(height: 10),
const Text(
'Votre mot de passe doit contenir :',
style: TextStyle(fontSize: 14, fontWeight: FontWeight.bold),
),
const SizedBox(height: 8),
_buildRequirement(_hasMinLength, 'Au moins 8 caractères'),
_buildRequirement(_hasUppercase, 'Une majuscule'),
_buildRequirement(_hasLowercase, 'Une minuscule'),
_buildRequirement(_hasDigit, 'Un chiffre'),
_buildRequirement(_hasSpecialChar, 'Un caractère spécial'),
],
);
}
Widget _buildRequirement(bool isMet, String text) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 2.0),
child: Row(
children: [
Icon(
isMet ? Icons.check_circle : Icons.circle_outlined,
color: isMet ? Colors.green : Colors.grey,
size: 16,
),
const SizedBox(width: 8),
Text(
text,
style: TextStyle(
color: isMet ? Colors.green : Colors.grey,
fontSize: 12,
),
),
],
),
);
}
}