getOriginalResource static method
Implementation
static Future<AlbumModelEntity?> getOriginalResource(String localIdentifier,
{void onProgress(double progress)?, void onError(String error)?}) async {
if (Platform.isIOS) {
//监听加载进度
_eventChannel.receiveBroadcastStream().listen((Object? object) {
if (object is double) {
if (onProgress != null) {
onProgress(object);
}
} else {
if (onError != null) {
onError(object.toString());
}
}
});
List list =
await _channel.invokeMethod('getOriginalResource', localIdentifier);
if (list.length == 0) {
if (onError != null) {
onError("加载失败,请重试");
}
return null;
}
AlbumModelEntity model = AlbumModelEntity.fromJson(list.first);
return model;
} else {
List list =
await _channel.invokeMethod('getOriginalResource', localIdentifier);
if (list.length == 0) {
if (onError != null) {
onError("加载失败,请重试");
}
return null;
}
List<AlbumModelEntity> album = <AlbumModelEntity>[];
try {
list.forEach((item) => album.add(AlbumModelEntity.fromJson(item)));
} catch (error) {
if (onError != null) {
onError(error.toString());
}
}
return album.first;
}
}