in my Flutter project I have a class Category witch contains a String, Icon, IconData and two Colors: (I don't want to store the icon, because I can recreate it with my iconData)
class Category {
Icon icon;
IconData iconData;
Color color;
Color backgroundcolor;
String name;
[...]
Map<String, dynamic> toMap() {
return {
'iconData': iconData,
'color': color,
'backgroundcolor': backgroundcolor,
'name': name
};
}
for my project I imported the sqflite database, created a table categories(with "CREATE TABLE categories(name TEXT, iconData BLOB, color BLOB, backgroundcolor BLOB")) and now want to insert a category into my database with the following:
Future<void> insertCategory(Category category) async {
// get reference to the database
final Database db = await database;
// insert new category
await db.insert('categories', category.toMap(),
conflictAlgorithm: ConflictAlgorithm.replace);
print("Category inserted.");
}
But when I try to insert a category I get an Argument Error (Invalid argument: Instance of 'IconData') and I can't figure out what's the problem.