Decidi dar uma mudada no projeto e usei as estrelas como "fases" e dificultei o level up de acordo com o level e fase
int level = 0;
int maxLevel = 20;
int maxStars = 5;
int nextLevel = 0;
SizedBox(
height: 50,
width: 60,
child: ElevatedButton(
onPressed: () {
setState(() {
for (var i = 0; i < maxStars + 1 - nextLevel; i++) {
int randomNumber = (Random().nextInt(10));
if (level < 5) {
if (randomNumber > 2) {
level++;
break;
}
} else if (level < 10) {
if (randomNumber > 5) {
level++;
break;
}
} else if (level < 15) {
if (randomNumber > 6) {
level++;
break;
}
} else if (level < 20) {
if (randomNumber > 8) {
level++;
break;
}
} else if (nextLevel < maxStars) {
nextLevel++;
level = 0;
break;
}
}
});
},
child: Container(
padding: const EdgeInsets.only(bottom: 5),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: const [
Icon(Icons.arrow_drop_up),
Text(
'Lvl Up',
style: TextStyle(fontSize: 10),
)
]),
),
),
)
Color setColor(int nextLevel, int level) {
if (nextLevel == 0) {
return Colors.blue.shade400;
} else if (nextLevel == 1) {
return Colors.green.shade400;
} else if (nextLevel == 2) {
return Colors.amber.shade400;
} else if (nextLevel == 3) {
return Colors.orange.shade400;
} else if (nextLevel == 4) {
return Colors.red.shade400;
} else if (nextLevel == 5 && level == 20) {
return Colors.black;
} else {
return Colors.deepPurple;
}
}