I am Trying To Pass List Of Objects To Isolate.spawan Method Using The Code Below
List<myContactsModel> sl=[myContactsModel(name:'ABcde',age:'34')];
var sls=jsonEncode(sl.toString());
Map map={
"sendPort":receivePort.sendPort,
"listContacts":sls,
};
isolate = await Isolate.spawn(sayHello,map);
The Map passes fine As A Parameter To sayHello function.
static void sayHello(Map map) async{
var sp=map['sendPort'];
List<myContactsModel> listContacts=jsonDecode(map['listContacts']);
sp.send("Hello from Isolate");
}
But When I Try To Get The Value of listContacts From Map And Store It In List listContacts it shows followinf error
Unhandled exception:
type 'String' is not a subtype of type 'List<myContactsModel>'