dart - Dart Polymer:X型不是Y型的子类型

标签 dart dart-polymer

我在PyCharm上使用Dart和Polymer开发我的应用程序。我目前有一个错误:

Exception: type 'ObservableList<DrugFilterItem>' is not a subtype of type 'ObservableList<DrugCompareItem>' of '__$orderFilterList@51385934'
ObservableList is from package:observe/src/observable_list.dart
DrugFilterItem is from package:synmed/drug_elements/views/drug_filter_menu.dart
ObservableList is from package:observe/src/observable_list.dart
DrugCompareItem is from package:synmed/drug_elements/views/drug_search_toolbar.dart

DrugFilterItem和DrugCompareItem都是自定义类,DrugCompareItem扩展了DrugFilterItem,由错误设计的行是:
ObservableList<DrugCompareItem> orderFilterList = new ObservableList<DrugFilterItem>();
这个问题今天突然发生了:我安装了Pycharm 2016.3并尝试编写代码,但是我的影子包出现了错误,我解决了。从那时起,我就遇到了这个错误,我认为这是由于软件包的问题引起的,因为代码在之前和之后都没有发生变化。

我现在发现的内容实际上是什么,我读了很多关于这种错误的文章,其中一个经常出现的问题是导入,但是我没有发现任何问题。我正在使用Dart 1.20.1和
polymer: "<=0.16.4+1"
core_elements: "<=0.7.1+3"
paper_elements: "<=0.7.1"

有人对我有什么线索吗?谢谢!

最佳答案

听起来像https://github.com/dart-lang/sdk/issues/14972#issuecomment-108402835

I believe this is working as intended. A List is not assignable to a List, even if it only contains Apples.

There are several ways to work around this:

iterable.map((x) => x) (removing the generic type),
new List<MethodMirror>.from(iterable)
new MyIterableWrapper<MethodMirror>(iterable) (where the iterable-wrapper that would need to be written).

关于dart - Dart Polymer:X型不是Y型的子类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40794351/

相关文章:

validation - Flutter FormBuilder Dropdown 验证不起作用

flutter - 如何在Dart中直接划分两个Duration对象?

dart - 如何从 Angular.Dart 组件内部引用聚合物组件

flutter - 即使我使用了安全区域,容器1也没有偏离屏幕底部,这在带有弯曲边缘的手机中看起来更糟

flutter - 如何在flutter中创建包含合并单元格的表格?

templates - 在 polymer Dart 中,我如何在重复模板中计数

polymer - 如何围绕我的 View 模型构建我的 Polymer SPA 和核心页面?

dart - 使用 Dart/Polymer 选择元素 : How to get index on-select

dart - polymer 元素在酒吧构建后不起作用 - 我忘记了什么吗?

dart - AngularDart对聚合物的不兼容版本限制