getOriginalResource static method

Future<AlbumModelEntity?> getOriginalResource(
  1. String localIdentifier, {
  2. void onProgress(
    1. double progress
    )?,
  3. void onError(
    1. String error
    )?,
})

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;
  }
}