takeSnapshot static method

Future<Uint8List> takeSnapshot(
  1. String username,
  2. String password, {
  3. required MediaUri snapshotUri,
})

Implementation

static Future<Uint8List> takeSnapshot(String username, String password,
    {required MediaUri snapshotUri}) async {
  final auth = base64.encode(utf8.encode('$username:$password'));

  final response = await Dio().get(snapshotUri.uri,
      options: Options(
          responseType: ResponseType.stream,
          headers: {'Authorization': 'BASIC $auth'}));

  final bytesBuilder = BytesBuilder();

  await for (final chunk in response.data.stream) {
    bytesBuilder.add(chunk);
  }

  return bytesBuilder.takeBytes();
}