Flutter如何转换列表< object>用于使用对象盒
我有一个类似此代码的模型
class Folder {
int id;
String title;
Color? color;
List<Note> notes;
final user = ToOne<User>();
String? get dbNotes => json.encode(notes);
set dbNotes(String? value) {
notes = json.decode(value!);
}
// ...
}
,并且有此错误
Cannot use the default constructor of 'Folder': don't know how to initialize param notes - no such property.
如何转换我的列表&lt; object&gt;存储在对象盒中?
I have a model like this code
class Folder {
int id;
String title;
Color? color;
List<Note> notes;
final user = ToOne<User>();
String? get dbNotes => json.encode(notes);
set dbNotes(String? value) {
notes = json.decode(value!);
}
// ...
}
and I have this error
Cannot use the default constructor of 'Folder': don't know how to initialize param notes - no such property.
How can I convert my List<Object> to store in ObjectBox?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以定义一个音符实体,并像文件夹一样与文件夹类创建一个与文件夹类别的关系。用户。
You can define a Note entity and create a To-One relation to the Folder class just like you did with Folder -> User.
请这样做:
您定义默认构造函数并初始化变量注释
folder(){notes =&lt; notes&gt; []; }
Please do this:
you define a default constructor and initialize the variable notes
Folder(){ notes = <Notes>[]; }