i have a question,
I have a custom class, which has a constructor. One of the parameters of the constructor is a function. so i call it like this:
TableWidget(table_number: "Table 1", iconcolor: getColor("Table 1", _DateSelectTable.getvalue())),.
The getColor function is not async, but inside that function i want to open a file using path provider, which is async. How can i make this work without getting errors?
Thanks a lot
*Edit: added the getColor function code:
getColor(tableNumber, date) {
final File file = File('assets/states1.txt');
lines = file.readAsLinesSync(encoding: utf8);
for(var line in lines){
if(line.substring(0, 7) == tableNumber){
if(line.substring(13, 15) == "${date.day}"){
return Colors.red;
}
}
}
return Colors.black;
}
What i want to do here and the reason why i am asking you is that instead of have the path to the file as 'assets/states1.txt' i want to use the get documents directory function, which is async. thank you.