forEachPart method
Runs onPart for each part, discarding any it did not read.
The convenience worth having: a part nobody reads stalls the request, because the next one cannot start until this one is off the connection. This makes forgetting impossible.
Implementation
Future<void> forEachPart(
FutureOr<void> Function(MultipartPart part) onPart,
) async {
await for (final part in parts) {
await onPart(part);
// Only when the callback left it alone; draining a consumed stream throws.
await part.skip();
}
}