I got this error while I am using isolates
I am not able to use both compute
function and Isolate.spawn
function both gives the same error.
I have also written WidgetsFlutterBinding.ensureInitialized();
in the main function
but then also this error comes.
Future<void> main() async{
WidgetsFlutterBinding.ensureInitialized();
final AppController appController = Get.put(AppController());
await appController.initializeSharedPreferencesAndDatabase();
String? data = appController.sharedPreferences!.getString(Constants.TOKEN);
if(data != null){
dataSaved = true;
}
else{
dataSaved = false;
}
runApp(const MyApp());
}
This is my main function
await Isolate.spawn(Utilities.downloadPdf, [
pdfUrl,
name,
chapter,
subject,
documentId
]);
here I am spawning my isolate like this.
This causes the error, I don't know why?
Please help