generateGender static method
Generates a gender code (SSSS) based on the provided gender
.
The gender
parameter specifies the gender ('female' or 'male').
Returns a string representing the generated gender code.
Implementation
static String generateGender(Gender? gender) {
late int min;
late int max;
if (gender != null) {
if (gender == Gender.FEMALE) {
min = 0;
max = 5000;
} else if (gender == Gender.MALE) {
min = 5000;
max = 10000;
}
} else {
min = 0;
max = 10000;
}
final int randInt = Random().nextInt(max - min) + min;
return randInt.toString().padLeft(4, '0');
}