string function

String string({
  1. List<String> pools = const [lower, upper, number, symbol],
  2. String self = '',
  3. int min = 5,
  4. int? max,
})

return a string with random character.

default pools is lower, upper, number and symbol. you also can provide self string. while max is null, min is the length of result. or the length is random between min to max.

Implementation

String string(
    {List<String> pools = const [lower, upper, number, symbol],
    String self = '',
    int min = 5,
    int? max}) {
  final pool = pools.join('') + self;
  var length = min;
  if (max != null) {
    length = integer(min: min, max: max);
  }
  final stringBuffer = StringBuffer();
  for (var i = 0; i < length; i++) {
    stringBuffer.write(pool[integer(max: pool.length - 1)]);
  }
  return stringBuffer.toString();
}