Hugo Cardin Hugo Cardin - 1 year ago 104
Dart Question

Dart Polymer : Type X is not a subtype of type Y

I develop my application with Dart and Polymer on PyCharm. I currently have an error :

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 and DrugCompareItem are both custom classes, DrugCompareItem extends DrugFilterItem, and the line designed by the error is :

ObservableList<DrugCompareItem> orderFilterList = new ObservableList<DrugFilterItem>();

The problem suddenly happened today : I installed Pycharm 2016.3 and tried to code, but I had an error with the package shadow, which I solved. Since, I have this error which I supposed came from a problem with the packages as the code didn't change from before to after.

What I have found for now is nothing in fact, I read a lot of post on this kind of error, one of the recurrent subject was the imports but I didn't find any problem with this. I am using Dart 1.20.1 and

polymer: "<=0.16.4+1"
core_elements: "<=0.7.1+3"
paper_elements: "<=0.7.1"

Do anyone has any clue for me? Thanks!

Answer Source

Sounds like

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: => x) (removing the generic type),
new List<MethodMirror>.from(iterable)
new MyIterableWrapper<MethodMirror>(iterable) (where the iterable-wrapper that would need to be written).
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download