jsonObjects<T> method
Implementation
Stream<T> jsonObjects<T>(
String method,
String path, {
int? pages,
Map<String, String>? headers,
Map<String, dynamic>? params,
String? body,
int statusCode = 200,
String? preview,
String? arrayKey,
}) async* {
headers ??= {};
if (preview != null) {
headers['Accept'] = preview;
}
headers.putIfAbsent('Accept', () => v3ApiMimeType);
await for (final response in fetchStreamed(
method,
path,
pages: pages,
headers: headers,
params: params,
body: body,
statusCode: statusCode,
)) {
final json = arrayKey == null
? jsonDecode(response.body) as List?
: (jsonDecode(response.body) as Map)[arrayKey];
for (final item in json) {
yield (item as T?)!;
}
}
}