getImageStreams method
Retrieves images as byte streams from a scan job.
host - The host server URL.
jobId - The ID of the scan job.
Returns a List<Uint8List> containing the byte streams of the images.
Implementation
Future<List<Uint8List>> getImageStreams(String host, String jobId) async {
final List<Uint8List> streams = [];
while (true) {
try {
var timestamp = DateTime.now().millisecondsSinceEpoch;
var url = '$host/DWTAPI/ScanJobs/$jobId/NextDocument?$timestamp';
final response = await http.get(Uri.parse(url));
if (response.statusCode == 200) {
streams.add(response.bodyBytes);
} else if (response.statusCode == 410 || response.statusCode == 404) {
break;
}
} catch (error) {
break;
}
}
return streams;
}