remove method

Future<bool> remove({
  1. bool useMemory = false,
  2. bool isFailTip = true,
})

Implementation

Future<bool> remove({
  bool useMemory = false,
  bool isFailTip = true,
}) async {
  await checkOrCreateDustbin;

  final bool exists = await assetExists;

  if (exists && !useMemory) {
    await File(path).rename(dustbinPath);
    logger.info('remove $path to $dustbinPath');
    return true;
  } else if (exists && useMemory && content != null) {
    await Future.wait([
      File(path).delete(),
      File(dustbinPath).writeAsBytes(content!),
    ]);
    logger.info('remove $path to $dustbinPath');
    return true;
  } else if (content != null) {
    await File(dustbinPath).writeAsBytes(content!);
    logger.info('remove $path to $dustbinPath');
    return true;
  } else if (isFailTip) {
    logger.warning(className, 'remove失败,asset和memory中不存在$path', StackTrace.current);
  }
  return false;
}