Getting error converting dart2js on polymer project

北慕城南 提交于 2019-12-05 23:23:29

I have not yet seen your Unsupported operation message. Maybe some recent change. Your NoSuchMethodError is common when a property of a class is only referenced by a polymer expression (HTML) because tree-shaking drops all code that is not referenced and polymer expressions are not evaluated for this yet. The @MirrorsUsed annotation helps bridging this gap.

The problem is in your Post class because it's properties are only referenced in polymer expressions

<div class="post">  
  <h3>{{ currentPost.ownerName }}</h3>
  <p>{{ currentPost.title }}</p>
  <p>This is the postId: {{ currentPost.key }}</p>
  <p class="timestamp">{{ currentPost.uploadTime }}</p>

To get your view updated when the properties in your currentPost change you should make your Post class like

class Post extends Object with Observable {
  @observable String ownerName;
  @observable String title;
  ...
}

If you have an annotation like @reflectable, @published, or @observable you don't need @MirrorsUsed.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!