You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am returning this model class from squadron worker. Why is it that this works on isolates but not on web workers ? I do not see any data type that should not be transferred from web worker but still I am getting an exception. There are fromJson and toJson methods that work on Dart VM but not on web.
That's because JavaScript knows nothing about Dart strong types and generics, so any List<T> and Map<K,V> crossing the Web worker boundary becomes a plain List<dynamic> and Map, dynamic, dynamic> on the receiving end.
Try changing factory HttpResponse.fromJson(final Map<String, Object?> json) to factory HttpResponse.fromJson(final Map json) and you should be OK.
But then, it will probably choke on as List<int> and as Map<String, dynamic>. To fix that and regain strong types, you can write this instead:
I am returning this model class from squadron worker. Why is it that this works on isolates but not on web workers ? I do not see any data type that should not be transferred from web worker but still I am getting an exception. There are
fromJson
andtoJson
methods that work on Dart VM but not on web.Here is the exception (Screenshot):
The text was updated successfully, but these errors were encountered: