Created
September 25, 2023 02:39
-
-
Save brownsoo/642741fcbfb445db881c6622cbb52bc6 to your computer and use it in GitHub Desktop.
dart iterable 에서 널러블 아이템 조회 확장함수
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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