1
resposta

[Dúvida] Mudança de de cor, mas o linear progress(barra) não chega até o final

Eu sabia como fazer só não sabia colocar em prática, e então eu olhei uns 5 projetos diferentes e fiz o meu.

class _TaskState extends State<Task> {
  int nivel = 0;
 int change=0;
 Color color= const Color.fromARGB(250, 26, 35, 100);
  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: const EdgeInsets.all(8.0),
      child: Stack(children: [
        Container(
          decoration: BoxDecoration(
            borderRadius: BorderRadius.circular(4),
color: color
          ),
          height: 140,
        ),
        Column(
          children: [
            Container(
              decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(4),
                color: Colors.white,
              ),
              height: 100,
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Container(
                    decoration: BoxDecoration(
                      borderRadius: BorderRadius.circular(4),
                      color: Colors.black26,
                    ),
                    width: 72,
                    height: 100,
                    child: ClipRRect(
                      borderRadius: BorderRadius.circular(4),
                      child: Image.asset(
                        widget.foto,
                        fit: BoxFit.cover,
                      ),
                    ),
                  ),
                  Column(
                    mainAxisAlignment: MainAxisAlignment.center,
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      SizedBox(
                          width: 200,
                          child: Text(
                            widget.nome,
                            style: const TextStyle(
                                fontSize: 24, overflow: TextOverflow.ellipsis),
                          )),
                      Difficulty(
                        difficultyLevel: widget.dificuldade,
                      )
                    ],
                  ),
                  SizedBox(
                    height: 52,
                    width: 52,
                    child: ElevatedButton(
                        onPressed: () {
                          setState(() {
                            if (nivel < change) {nivel++;}
                            else {
                            nivel = 1;
                            change = change +10;
                            switch(change){
                            case 10:
                            color=const Color.fromARGB(150, 0, 150, 0);
                            break;
                            case 20:
                            color=const Color.fromARGB(250,150, 0, 250);
                            break;
                            case 30:
                            color= const Color.fromARGB(250, 200, 50, 0);
                            break;
                            case 40:
                            color= const Color.fromARGB(220, 0, 0, 210);
                            break;
                            case 50:
                            color= const Color.fromARGB(200, 200, 20, 200);
                            break;
                            default:
                            color=const Color.fromARGB(200,200, 0, 0);
                            }

                            }


                          });
Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                Padding(
                  padding: const EdgeInsets.all(8),
                  child: SizedBox(
                    width: 200,
                    child: LinearProgressIndicator(
                      backgroundColor: Colors.white,
                        value: (widget.dificuldade > 0)
                            ? (nivel / widget.dificuldade ) / 10
                           : 1 ,
                      color: Colors.blue
    ),
1 resposta

Massa! valeu por compartilhar :D