Olá, Desafio feito #compartilhando
// task.dart
import 'package:flutter/material.dart';
import 'difficult.dart';
class Task extends StatefulWidget {
final String nameTask;
final String srcImage;
final int difficult;
const Task(
{required this.nameTask,
required this.srcImage,
required this.difficult,
super.key});
@override
State<Task> createState() => _TaskState();
}
class _TaskState extends State<Task> {
int nivel = 0;
int master = 1;
late Color color;
@override
Widget build(BuildContext context) {
switch (master) {
case 1:
color = Colors.blue;
break;
case 2:
color = Colors.green;
break;
case 3:
color = Colors.amber;
break;
case 4:
color = Colors.orange;
break;
case 5:
color = Colors.redAccent;
break;
case 6:
color = Colors.purpleAccent;
break;
case 7:
color = Colors.black;
break;
}
return Padding(
padding: const EdgeInsets.all(8.0),
child: Stack(
children: [
Container(
height: 140,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(4),
color: color,
),
),
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.srcImage,
fit: BoxFit.cover,
),
),
),
Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
width: 200,
child: Text(
widget.nameTask,
style: const TextStyle(
fontSize: 24, overflow: TextOverflow.ellipsis),
),
),
Difficulty(difficultyLevel: widget.difficult)
],
),
SizedBox(
height: 64,
width: 80,
child: ElevatedButton(
onPressed: () {
if (master <= 7) {
setState(() {
nivel++;
if (nivel >= widget.difficult * 10) {
nivel = 1;
master++;
}
});
}
},
// O resto é igual