0

The Flutter ObjectBox docs state:

ObjectBox (Java, Dart) has built-in support for String lists. ObjectBox for Java also has built-in support for String arrays.

However, using a List<String> in a converter triggers the following warning:

[WARNING] objectbox_generator:resolver on lib/model/diary_day.dart: Skipping property 'doneExercises': type 'List' not supported, consider creating a relation for @Entity types (https://docs.objectbox.io/relations), or replace with getter/setter converting to a supported type (https://docs.objectbox.io/advanced/custom-types).

So the question now is, is this a bug, or am I misunderstanding the docs?

Just for reference, the converter looks like:

late List<DiaryExercise> doneExercises = [];

List<String> get dbDoneExercises {
  List<String> retVal = [];
  for (DiaryExercise thisExercise in doneExercises) {
    retVal.add(jsonEncode(thisExercise.toJson()));
  }
  return retVal;
}

set dbDoneExercises(List<String> jsonStrings) {
  for (String thisJson in jsonStrings) 
    DiaryExercise exercise = DiaryExercise.fromJson(jsonDecode(thisJson));
    doneExercises.add(exercise);
  }
}
SePröbläm
  • 5,142
  • 6
  • 31
  • 45
  • 1
    List is supported, however the warning is about List. As you added a converter, you might want to add `@Transient()` to `doneExercises` to silence the warning. I will update the docs as well. – Uwe - ObjectBox Feb 06 '23 at 11:22
  • @Uwe-ObjectBox Thank you very much for the clarification. ObjectBox is pretty awesome btw.. Thanks for providing it. – SePröbläm Feb 06 '23 at 11:59

1 Answers1

0

Turned out, it's just a warning. A look into objectbox-model.json revealed the List<String> converter is used.

SePröbläm
  • 5,142
  • 6
  • 31
  • 45