startPrint method
Implementation
@override
Future startPrint(String path, String info,{String? printerName}) async {
// TODO: implement startPrint
if (path.isEmpty) {
return {
"res": false,
"info": "path is empty"
};
}
var btwFile = File(path);
if (!btwFile.existsSync()) {
return {
"res": false,
"info": "btwFile is not exist"
};
}
String type = btwFile.path.substring(btwFile.path.lastIndexOf(".") + 1);
if (type != "btw") {
return {
"res": false,
"info": "$type is an unqualified format"
};
}
ReceivePort receivePort = ReceivePort();
Isolate backgroundTask = await Isolate.spawn(startBackground, {
"send": receivePort.sendPort,
"instance": RootIsolateToken.instance!,
"path": path,
"info": info,
"printerName": printerName
});
var resInfo = await receivePort.first;
backgroundTask.kill(priority: Isolate.immediate);
receivePort.close();
return resInfo;
}