I have created an automatic task creation in which i have 4 fields
Enddate, taskname, description and duedate.
When i generating the output to the function its working fine but i am not able to store the value of duedate in the database (supbase) rest all values are going.
duedate is itreating and its should automatically go into the databse with recurring due dates as its working in function
Can anyone help me this
String? automatictasktestingfucntion(
String? enddate,
String? taskname,
String? description,
String? duedate,
) {
/// MODIFY CODE ONLY BELOW THIS LINE
// Check if any of the required arguments are missing
if (enddate == null || taskname == null || description == null) {
return null;
}
// Parse the end date
final formatter = DateFormat('yyyy-MM-dd');
final endDate = formatter.parse(enddate);
// Get the current date
final currentDate = DateTime.now();
// Create a list to store task messages
final List<String> taskMessages = [];
// Iterate from the current date until the end date, creating tasks for each Tuesday
for (DateTime date = currentDate;
date.isBefore(endDate.add(Duration(days: 1))); // Include end date
date = date.add(Duration(days: 1))) {
if (date.weekday == DateTime.tuesday) {
// Create due date based on the current date
final dueDate =
date.subtract(Duration(days: date.weekday - DateTime.tuesday));
// Create a task message with the provided details, end date, and due date
final taskMessage =
'Task: $taskname\nDescription: $description\nEnd Date: ${formatter.format(endDate)}\nDue Date: ${formatter.format(dueDate)}';
taskMessages.add(taskMessage);
}
}
// Combine task messages into a single string separated by newlines
final combinedTaskMessages = taskMessages.join('\n');
return combinedTaskMessages;
/// MODIFY CODE ONLY ABOVE THIS LINE
}