https://drive.google.com/file/d/11rp6m7Yi8gbaJYsZ8ofV2XpBrTjOvbNs/view?usp=share_link
static const String _tablename = 'tasks';
static const String _name = 'name';
static const String _difficulty = 'difficulty';
static const String _image = 'image';
static const String _level = 'level';
static const String _index = 'cindex';
static const String tableSql = 'CREATE TABLE $_tablename('
'$_name TEXT, '
'$_difficulty INT, '
'$_image TEXT, '
'$_level INT, '
'$_index INT)';
List<Task> toList(List<Map<String, dynamic>> mapaDeTarefas) {
final List<Task> tarefas = [];
for (Map<String, dynamic> linha in mapaDeTarefas) {
final Task tarefa = Task(linha[_name], linha[_image], linha[_difficulty], linha[_level], linha[_index]);
tarefas.add(tarefa);
}
return tarefas;
}
Map<String,dynamic> toMap(Task tarefa){
final Map<String,dynamic> mapaDeTarefas = Map();
mapaDeTarefas[_name] = tarefa.nome;
mapaDeTarefas[_difficulty] = tarefa.dificuldade;
mapaDeTarefas[_image] = tarefa.foto;
mapaDeTarefas[_level] = tarefa.level;
mapaDeTarefas[_index] = tarefa.index;
return mapaDeTarefas;
}
child: ElevatedButton(
onPressed: () {
setState(() {
widget.level++;
if ((widget.level / widget.dificuldade) / 10 > 1) {
if (widget.index < 6) {
widget.level = 0;
widget.index++;
}
}
}
);
TaskDao().save(widget);
},