Created
May 7, 2019 01:20
-
-
Save wyattbiker/55f20064275b7a70e01aab52b3bd505b to your computer and use it in GitHub Desktop.
Get random filename
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:math'; | |
void main() { | |
print(getRandFilename(8)); | |
} | |
String getRandFilename(int fileNameLength) { | |
Random r = Random(); | |
int randF = pow(10, fileNameLength); | |
randF = r.nextInt(randF); | |
return(randF.toString().padLeft(fileNameLength, '0')); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment