streamOne method
Stream<Map<String, Object?> >
streamOne({
- required StreamBody body,
- String? authorization,
override
Implementation
@override
Stream<Map<String, Object?>> streamOne({
required StreamBody body,
String? authorization,
}) async* {
final response = await _client.request(
method: 'GET',
path: '/db/stream',
headers: {'authorization': authorization},
body: body,
);
final stream = response.transform(utf8.decoder);
yield* stream
.map((event) {
if (jsonDecode(event) case {'data': final Map data}) {
return data.map((key, value) => MapEntry((key as String), value));
}
throw Exception('Invalid response');
})
.handleError((_) {
// do nothing
});
}