Essa foi a solução que consegui achar. Acho q ficou um pouco poluído, mas acredito que de pra entender.
class _TaskState extends State<Task> {
int nivel = 0;
int maestria = 0;
double valor = 0;
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.all(8.0),
child: Stack(
children: [
Container(
height: 140,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(4),
color: (maestria == 0)
? (Colors.blue)
: ((maestria == 1)
? (Colors.green)
: (((maestria == 2)
? (Colors.purple)
: ((maestria == 3)
? (Colors.amber)
: ((maestria == 4)
? (Colors.red)
: (Colors.red)))))),
)
),
.
.
.
SizedBox(
width: 52,
height: 52,
child: ElevatedButton(
onPressed: () {
setState(() {
aumentoMaestria();
});
},
child: Column(
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.end,
children: const [
Icon(Icons.arrow_drop_up),
Text(
'Up',
style: TextStyle(
fontSize: 12,
),
),
],)
),
)
],)
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: SizedBox(
width: 200,
child: LinearProgressIndicator(
color: Colors.white,
value: (widget.dificuldade > 0)
? nivel / (widget.dificuldade * 10)
: 1),
)),
Padding(
padding: const EdgeInsets.all(12.0),
child: Text(
'Nível: $nivel',
style:
const TextStyle(color: Colors.white, fontSize: 16),
),
),
],
)
],
)
],
));
}
void aumentoMaestria() {
nivel++;
if (maestria > 4) {
maestria -= 5;
}
return setState(() {
if (nivel / (widget.dificuldade * 10) == 1) {
maestria++;
nivel = 0;
}
});
}
}