Files
proxypin/lib/network/util/lists.dart
2024-09-02 02:38:46 +08:00

21 lines
393 B
Dart

///获取list元素类型
/// @author wanghongen
Type getListElementType(dynamic list) {
if (list == null || list.isEmpty || list is! List) {
return Null;
}
var type = list.first.runtimeType;
return type;
}
dynamic getFirstElement(List? list) {
return list?.firstOrNull;
}
//转换指定类型
List<T> convertList<T>(List list) {
return list.map((e) => e as T).toList();
}