-
I have a simple list of string that want to save into a table column, here is the converter I wrote, but it has many errors on the override method. (Please read the comment from the codes)
I don't understand why the invalid override means. I can't find the documentation that explain this. Since this is a simple string list, do i need a |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Thank you for starting this discussion. The example from the docs has not been migrated to null safety, which I think is causing the confusion here. Something like this should work, the docs should update soon class ListConverter extends TypeConverter<List<String>, String>{
const ListConverter();
@override
List<String>? mapToDart(String? fromDb) {
if (fromDb == null || fromDb == '') {
return null;
}
return json.decode(fromDb);
}
@override
String? mapToSql(List<String>? value) {
if (value == null || value.length == 0) {
return null;
}
return json.encode(value);
}
}
|
Beta Was this translation helpful? Give feedback.
Thank you for starting this discussion. The example from the docs has not been migrated to null safety, which I think is causing the confusion here.
Something like this should work, the docs should update soon