mirror of
https://github.com/wanghongenpin/proxypin.git
synced 2026-04-20 21:49:27 +08:00
21 lines
393 B
Dart
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();
|
|
}
|