saveImageWithPath method

Future<AssetEntity?> saveImageWithPath(
  1. String path, {
  2. required String title,
  3. String? desc,
  4. String? relativePath,
})

Implementation

Future<AssetEntity?> saveImageWithPath(
  String path, {
  required String title,
  String? desc,
  String? relativePath,
}) async {
  final File file = File(path);
  if (!file.existsSync()) {
    assert(false, 'File must exists.');
    return null;
  }
  final Map<dynamic, dynamic>? result = await _channel.invokeMethod(
    PMConstants.mSaveImageWithPath,
    <String, dynamic>{
      'path': path,
      'title': title,
      'desc': desc ?? '',
      'relativePath': relativePath,
      ...onlyAddPermission,
    },
  );
  if (result == null) {
    return null;
  }
  return ConvertUtils.convertMapToAsset(
    result.cast<String, dynamic>(),
    title: title,
  );
}