jeudi 25 mars 2021

Flutter how to generate random strings

Hello does anyone know how I can only generate Strings with letters. Like :

"skdnjfsd" or "bdfvkjnd" ?

my current code :

String _randomString(int length) {
    var rand = new Random();
    var codeUnits = new List.generate(
        length,
            (index){
          return rand.nextInt(33)+89;
        }
    );

    return new String.fromCharCodes(codeUnits);
  }



Aucun commentaire:

Enregistrer un commentaire