I am wondering whether I can create a function for my repository with which I can generically change any value within a variable which is based on a data class. Is this possible, how?
List<Task> tasks;
Future<void> changeTaskValue(int taskId, String variable, dynamic newValue) {
task[taskId].<magic to get a reference to the variable> = newValue;
}
class Task {
Task({this.taskId, this.taskName, this.status, });
final int taskId;
final String taskName;
final String status;
}
...
void function abc() {
changeTaskValue(taskId: 1, variable: 'taskName', newValue: 'test')
}