getImageStreams method

Future<List<Uint8List>> getImageStreams(
  1. String host,
  2. String jobId
)

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 = [];
  final url = '$host/DWTAPI/ScanJobs/$jobId/NextDocument';

  while (true) {
    try {
      final response = await http.get(Uri.parse(url));
      if (response.statusCode == 200) {
        streams.add(response.bodyBytes);
      } else if (response.statusCode == 410) {
        break;
      }
    } catch (error) {
      break;
    }
  }

  return streams;
}