提交 077207c7 authored 作者: shixiaochen's avatar shixiaochen

1、IterableExt增加扩展函数containsKey(通过比对集合内对象唯一属性,判断是否包含该元素);

上级 5416d3b5
......@@ -38,4 +38,6 @@
* 网络请求兼容data返回null
* ## 1.1.9
* 修复BaseListWidget展示多个loading问题
* ## 1.2.0
* IterableExt增加扩展函数containsKey(通过比对集合内对象唯一属性,判断是否包含该元素)
\ No newline at end of file
......@@ -25,6 +25,15 @@ extension IterableExt<E> on Iterable<E>? {
bool isNullOrEmpty() {
return this == null || this!.isEmpty;
}
bool containsKey(elementKey, {String key = "id"}) {
if (this == null) return false;
for (E e in this!) {
if ((e as Map?)?[key] == elementKey) return true;
}
return false;
}
}
/// 扩展函数 GlobalKey
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论