2 / 2
Aug 2024
import 'package:realm/realm.dart'; part 'command.realm.dart'; @RealmModel() class _Command { @PrimaryKey() late ObjectId id; late String command; late String status; late DateTime tagab; }

Hello, I am trying to have a class named UserDatabase that will have a parameter “List commands”. Where the Command class is provided above. After running:dart run realm generate The Command class was generated successfully. Now I am trying to create the UserDatabase class like this:

import 'package:realm/realm.dart'; import 'command.dart'; part 'user_database.realm.dart'; @RealmModel() class _UserDatabase { @PrimaryKey() late ObjectId id; late String user_id; late List<Command> commands; }

And when running dart run realm generate, I get this output:

5@RealmModel() 6class _UserDatabase { │ ━━━━━━━━━━━━━ in realm model for 'UserDatabase' ... │ 11 │ late List<Command> commands; │ ^^^^^^^^^^^^^ List<InvalidType> is not a realm model type

Where am I wrong? Thank you.

I tried changing List to RealmList, but it didn’t work.
Also tried: RealmList<_Command>. And tried to define the command class as $Command but it didn’t do the job