byNameOrNull method

T? byNameOrNull(
  1. String? value, {
  2. bool caseSensitive = true,
})

Implementation

T? byNameOrNull(
  String? value, {
  bool caseSensitive = true,
}) {
  if (value == null) return null;

  for (final item in this) {
    if (caseSensitive) {
      if (item.name == value) return item;
    } else {
      if (item.name.toLowerCase() == value.toLowerCase()) {
        return item;
      }
    }
  }

  return null;
}