password_strength_indicator
一个 Flutter 包,用于使用可自定义的强度条直观地评估密码强度。
特点
- 使用强度条直观地表示密码强度。
- 自定义强度条的宽度、厚度、半径和颜色。
- 控制动画持续时间和曲线,以实现流畅的用户体验。
- 定义一个回调函数,以接收密码的强度值。
- 实现自定义的强度构建器,根据您自己的标准计算密码强度。
- 为强度条的外观选择不同的样式。
截图

安装
要使用此包,请在您的 pubspec.yaml 文件中将 password_strength_indicator 添加为依赖项。
用法
导入包
import 'package:password_strength_indicator/password_strength_indicator.dart';
要使用 PasswordStrengthIndicator 小部件,只需提供所需的参数
PasswordStrengthIndicator(
width: 200, // Change the width of the strength bar
thickness: 12, // Change the thickness of the strength bar
backgroundColor: Colors.grey, // Change the background color of the strength bar
radius: 8, // Change the radius of the strength bar
colors: StrengthColors(
// Customize the colors of the strength bar
weak: Colors.orange,
medium: Colors.yellow,
strong: Colors.green,
),
duration: Duration(milliseconds: 300), // Set the animation duration
curve: Curves.easeOut, // Set the animation curve
callback: (double strength) {
// Receive the strength value of the password
print('Password Strength: $strength');
},
strengthBuilder: (String password) {
// Implement a custom strength builder to calculate the strength based on your criteria
// Return a value between 0.0 (too weak) and 1.0 (very strong)
// Example:
return password.length / 10;
},
style: StrengthBarStyle.line, // Choose a style for the strength bar
),
贡献
欢迎为该包做出贡献!如果您发现错误或有任何建议,请随时在 GitHub 仓库 上打开问题或提交拉取请求。
许可证
此包根据 MIT 许可证发布。有关详细信息,请参阅 许可证。
由 Thaanu Perera ❤️ 开发
如果您觉得此包有用,请考虑在 pub.dev 上给它一个 ⭐。编码愉快!