FindFirstItemOfType<TItem extends Item> static method

TItem? FindFirstItemOfType<TItem extends Item>(
  1. Iterable<Item> items
)
Finds the first item of type TItem (not a descendant type) in the specified collection. The collection.

Implementation

static TItem? FindFirstItemOfType<TItem extends Item>(Iterable<Item> items) {
  for (Item item in items) {
    // We're looking for an exact class match here.
    if (item.runtimeType == TItem) {
      return item as TItem?;
    }
  }

  return null;
}