Closed rbrinda029 closed 4 years ago
Exception has occurred. SqfliteDatabaseException (DatabaseException(java.lang.String cannot be cast to java.lang.Integer) sql 'INSERT INTO Photos_Answers (photo_id, que_id, img_path, created_audit_id, updated_at, created_at, date, time) VALUES (NULL, ?, ?, ?, ?, ?, ?, ?)' args [1, [/storage/emulated/0/Android/data/com.trevor.seears/files/Pictures/35bd4580-56c6-432f-a80d-de9ea527317f1747453282.jpg], 1, 31-01-2020 03:02:15, 31-01-2020 03:02:15, 31-01-2020, 03:02:15]})
You can just seperate those imagepath value with , and then store in sqlflite it's easiest solution.
import 'dart:convert';
import 'dart:io';
class PhotosAnswersData { int photoId = 0; String queId;
List imgPath;
String createdAuditId;
String date;
String time;
String createdAt;
String updatedAt;
PhotosAnswersData.withId({ this.photoId, this.queId, this.imgPath, this.createdAuditId, this.date, this.time, this.createdAt, this.updatedAt, });
PhotosAnswersData({ this.photoId, this.queId, this.imgPath, this.createdAuditId, this.date, this.time, this.createdAt, this.updatedAt, });
factory PhotosAnswersData.fromJson(String str) => PhotosAnswersData.fromMap(json.decode(str));
String toJson() => json.encode(toMap());
factory PhotosAnswersData.fromMap(Map<String, dynamic> json) => PhotosAnswersData.withId( photoId: json["photo_id"] == null ? null : json["photo_id"], queId: json["que_id"] == null ? null : json["que_id"], // imgPath: json["img_path"] == null ? null : json["img_path"],
Map<String, dynamic> toMap() => { "photo_id": photoId == null ? null : photoId, "que_id": queId == null ? null : queId, // "img_path": imgPath == null ? null : imgPath,
}
// Create table String photosAnsSql = "CREATE TABLE $tablePhotosAns($photosAns_photo_id INTEGER PRIMARY KEY, $photosAns_que_id TEXT, " + "$photosAns_created_audit_id TEXT, $photosAns_img_path TEXT, " + "$col_date TEXT, $col_time TEXT, $col_created_at TEXT, $col_updated_at TEXT)";
//Insert data Future insertPhotos(PhotosAnswersData photosAnswersData) async {
print("que_id type " + photosAnswersData.queId.runtimeType.toString());
}