I am trying to generate a string or password. where the user defines minimum numbers or special characters. if the minimum number is 3 then generated string should have 3 numbers
here is the code i used to generate string
String generaterandomPassword() {
final length = _length.toInt();
const letterLowerCase = "abcdefghijklmnopqrstuvwxyz";
const letterUpperCase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const number = '0123456789';
const special = '@#%^*>\$@?/[]=+';
String chars = "";
// if (letter) chars += '$letterLowerCase$letterUpperCase';
if (_uppercaseatoz) chars += letterUpperCase;
if (_lowercaseatoz) chars += letterLowerCase;
if (_number) chars += number;
if (_specialchar) chars += special;
return List.generate(
length,
(index) {
final indexRandom = Random.secure().nextInt(chars.length);
return chars[indexRandom];
},
).join('');
}