gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 04:05:04 25 4
gpt4 key购买 nike

我在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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com