ethanblake4 / dart_eval

Extensible Dart interpreter for Dart with full interop
https://pub.dev/packages/dart_eval
BSD 3-Clause "New" or "Revised" License
334 stars 40 forks source link

$List<E> add element failed in dart_eval ,throw type '$Data' is not a subtype of type 'Data' of 'value' #176

Closed yanweimin7 closed 9 months ago

yanweimin7 commented 9 months ago

sorry my pool english

I want add a element to list(exist outside of dart_eval) in dart_eval runtime. i use code like this

 final a = Data();
 a.name = "c";
DataManager().dataList.add(a);

it throw error:

type '$Data' is not a subtype of type 'Data' of 'value'

DataManager:

@Bind()
class DataManager {
  static final DataManager singleton = DataManager.internal();

  factory DataManager() {
    return singleton;
  }
  DataManager.internal();

  List<Data> dataList = [];
}

i think it's a bug from $List image

when add element ,its should add value.$value.

(target!.$value as List).add(value.$value);
ethanblake4 commented 9 months ago

Fixed in v0.7.5 using the new writeback-capable $List.view() (see #162). If you re-run dart_eval bind it should automatically generate this for you.