Quando eu scrollo a tela o valor do nivel volta zerado, tem um link para o git mostrando o que está acontecendo. ( não consegui colocar aqui no forum)
class Task extends StatefulWidget {
const Task(this.nome, {Key? key}) : super(key: key);
final String nome;
@override
State<Task> createState() => _TaskState();
}
class _TaskState extends State<Task> {
int nivel = 0;
@override
Widget build(B![Insira aqui a descrição dessa imagem para ajudar na acessibilidade](https://cdn1.gnarususercontent.com.br/1/1279021/375949e6-531b-457b-a30f-8ab4c66d1103.png) uildContext context) {
return Padding(
padding: const EdgeInsets.all(8.0),
child: Stack(
children: [
Container(
color: Colors.blue,
height: 140,
),
Column(
children: [
Container(
color: Colors.white,
height: 100,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
color: Colors.black26,
width: 72,
height: 100,
),
SizedBox(
width: 200,
child: Text(
widget.nome,
style: const TextStyle(
fontSize: 24,
overflow: TextOverflow.ellipsis,
),
),
),
ElevatedButton(
onPressed: () {
setState(() {
nivel++;
});
},
child: const Icon(Icons.arrow_drop_up),
)
],
),
),
Text('Nivel: $nivel',
style: TextStyle(
color: Colors.white,
fontSize: 16,
))
],
),
],
),
);
}
}
))