prep method
Prepares the batch of items for processing.
This method retrieves the list of items from the node's parameters. It
expects a parameter named "items" which should be a List<I>.
Throws an ArgumentError if the "items" parameter is not provided or is of the wrong type.
Implementation
@override
/// Prepares the batch of items for processing.
///
/// This method retrieves the list of items from the node's parameters. It
/// expects a parameter named "items" which should be a `List<I>`.
///
/// Throws an [ArgumentError] if the "items" parameter is not provided or is
/// of the wrong type.
Future<List<I>> prep(Map<String, dynamic> shared) async {
final items = params['items'] ?? shared['items'];
if (items == null) {
throw ArgumentError('The "items" parameter must be provided.');
}
if (items is List<I>) {
return items;
}
if (items is List) {
if (items.every((item) => item is I)) {
return items.cast<I>();
} else {
throw ArgumentError(
'The "items" parameter must be a List where all elements are of '
'type $I.',
);
}
}
throw ArgumentError(
'The "items" parameter must be a List, but got ${items.runtimeType}.',
);
}