getUsedThreshold function

int getUsedThreshold(
  1. String password,
  2. String entry,
  3. int threshold
)

Implementation

int getUsedThreshold(
  String password,
  String entry,
  int threshold,
) {
  bool isPasswordToShort = password.length <= entry.length;
  bool isThresholdLongerThanPassword = password.length <= threshold;
  bool shouldUsePasswordLength =
      isPasswordToShort || isThresholdLongerThanPassword;

  // if password is too small use the password length divided by 4 while the
  // threshold needs to be at least 1
  return shouldUsePasswordLength ? (password.length / 4).ceil() : threshold;
}