collection
collection copied to clipboard
[Proposal] Add `firstWhereType`
We already have whereType, but it would be great to get the first occurrence of the given type.
Here's a use case where this could come in hand.
final results = await Future.wait(
[
_metadataService.getTableMetadata(tableId),
_dataService.getTableData(tableId),
],
eagerError: true,
);
final metadata = results.whereType<TableMetadata>().first;
final data = results.whereType<TableRawData>().first;
It could be replaced with
final metadata = results.firstWhereType<TableMetadata>();
final data = results.firstWhereType<TableRawData>();