Dart Isolate Error: Illegal argument in isolate message: object is unsendable
I'm trying to use Dart isolates to offload JSON parsing in my Flutter package. However, when I run the following function, I get an error about an "unsendable object" in isolate messages.
Future
Error
Invalid argument(s): Illegal argument in isolate message: object is unsendable
- Library:'dart:async' Class: _Future@4048458
(see restrictions listed at `SendPort.send()` documentation for more information)
<- _streamFuture in Instance of '_HttpClientConnection' (from dart:_http)
<- hashCode in Instance of '_HashSetEntry<_HttpClientConnection>' (from dart:collection)
<- _List len:8 (from dart:core)
<- _buckets in Instance of '_HashSet<_HttpClientConnection>' (from dart:collection)
<- _idle in Instance of '_ConnectionTarget' (from dart:_http)
<- value in Instance of '_HashMapEntry' (from dart:collection)
<- _List len:8 (from dart:core)...
- Changing _requestAndContent to be synchronous instead of async
- response.body.toString()