Can anyone tell me whats wrong in this code?
void onPressed() async {
//Navigator.pushNamed(context, "/screen2", arguments: []);
var receivePort = ReceivePort();
await Isolate.spawn(gotoNext, [receivePort.sendPort]);
final msg = await receivePort.first;
print(msg);
}
void gotoNext(List<dynamic> args) {
SendPort sendPort = args[0];
log(args.toString());
Isolate.exit(sendPort, "OK");
}
E/flutter (12062): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: Invalid argument(s): Illegal argument in isolate message: (object extends NativeWrapper - Library:'dart:ui' Class: Path)