I have a field, “designName,” that I carry over from a “project” page to one where I enter tasks, and want to insert in a SQFLITE column. For some reason, it can’t get it to insert on the first entry, but only on the “updates.”
Future<void> _addItem(String designName, String taskName, String taskType, String taskActivityArea, String taskFunction, String taskComment) async {
await SQLHelperTasks.createItem(
_designNameController.text,
_taskNameController.text,
_taskTypeController.text,
_taskActivityAreaController.text,
_taskFunctionController.text,
_taskCommentController.text);
_refreshTasks();
}
The corresponding code in the “SQLHelper” file:
static Future<int> createItem(String designName,
String taskName,
String? taskType,
String? taskActivityArea,
String? taskFunction,
String? taskComment) async {
final db = await SQLHelperTasks.db();
final data = {'designName': designName,
'taskName': taskName,
'taskType': taskType,
'taskActivityArea': taskActivityArea,
'taskFunction': taskFunction,
'taskComment': taskComment};
final id = await db.insert('items', data,
conflictAlgorithm: sql.ConflictAlgorithm.replace);
return id;
}
The “updates” are basically identical:
Future<void> _updateItem(id, String designName, String taskName, String taskType, String taskActivityArea, String taskFunction, String taskComment) async {
await SQLHelperTasks.updateItem(
id, _designNameController.text,
_taskNameController.text,
_taskTypeController.text,
_taskActivityAreaController.text,
_taskFunctionController.text,
_taskCommentController.text);
_refreshTasks();
}
And:
static Future<int> updateItem(
int id,
String designName,
String taskName,
String? taskType,
String? taskActivityArea,
String? taskFunction,
String? taskComment) async {
final db = await SQLHelperTasks.db();
final data = {
'designName': designName,
'taskName': taskName,
'taskType': taskType,
'taskActivityArea': taskActivityArea,
'taskFunction': taskFunction,
'taskComment': taskComment,
'createdAt': DateTime.now().toString()
};
Just having trouble with that one field…
Any suggestions?
I can add more code if necessary.