performScan method
Implementation
Future<JobState> performScan(
ScanParameters scanParams, List<String> outScannedPaths) async {
var params = {"connector": this.toMap(), "scanParams": scanParams.toMap()};
final Map<dynamic, dynamic> resultMap =
await AirBrother._channel.invokeMethod("performScan", params);
JobState jobState = JobState.fromMap(resultMap["jobState"]);
List<dynamic> scannedPaths = resultMap["scannedPaths"];
print("Scans Received ${scannedPaths}");
// The Brother iOS Lib does not currently support all the papers supported
// by the Android SDK.
// We'll handle those paper conversions on the Flutter side.
if (Platform.isIOS &&
!scanParams.autoDocumentSizeScan &&
(scanParams.documentSize == MediaSize.A4 ||
scanParams.documentSize == MediaSize.A5 ||
scanParams.documentSize == MediaSize.A6 ||
scanParams.documentSize == MediaSize.B4 ||
scanParams.documentSize == MediaSize.B5 ||
scanParams.documentSize == MediaSize.C5Envelope ||
scanParams.documentSize == MediaSize.DLEnvelope ||
scanParams.documentSize == MediaSize.Index4x6 ||
scanParams.documentSize == MediaSize.Executive ||
scanParams.documentSize == MediaSize.Hagaki ||
scanParams.documentSize == MediaSize.Folio ||
scanParams.documentSize == MediaSize.BusinessCardLandscape)) {
for (int i = 0; i < scannedPaths.length; i++) {
String scannedPath = scannedPaths[i];
MediaSize requestedMedia = scanParams.documentSize;
String croppedPath = await _getUpdatedSizePath(
path: scannedPath,
widthIn: requestedMedia._width,
heightIn: requestedMedia._height);
outScannedPaths.add(croppedPath);
}
}
else {
scannedPaths.forEach((element) {
outScannedPaths.add(element);
});
}
return jobState;
}