Skip to content

Instantly share code, notes, and snippets.

@brownsoo
Created September 25, 2023 02:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brownsoo/642741fcbfb445db881c6622cbb52bc6 to your computer and use it in GitHub Desktop.
Save brownsoo/642741fcbfb445db881c6622cbb52bc6 to your computer and use it in GitHub Desktop.
dart iterable 에서 널러블 아이템 조회 확장함수
extension NullIterable<E> on Iterable<E> {
E? getFirstOrNull(bool test(E element)) {
try {
return this.firstWhere(test);
} catch (e) {
return null;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment