TA的每日心情 | 奋斗 2024-4-10 21:41 |
---|
签到天数: 212 天 [LV.7]超级吧粉
|
发表于 2024-4-10 21:43:08
|
显示全部楼层
extension FirstWhereExt<T> on List<T> {
/// The first element satisfying [test], or `null` if there are none.
T? firstWhereOrNull(bool Function(T element) test) {
for (var element in this) {
if (test(element)) return element;
}
return null;
}
} |
|