deleteEmptyFile static method

Future<bool> deleteEmptyFile(
  1. String filename
)

Implementation

static Future<bool> deleteEmptyFile(String filename) async {
  File readFile = File(filename);
  if (!await FileSystemEntity.isFile(filename))
    throw ArgumentError(filename + " is not a file");
  if ((await readFile.length()) == 0 && (await readFile.exists())) {
    try {
      await readFile.delete();
      return true;
    } catch (e) {
      print("Could not delete file " + (await readFile).path);
    }
  }
  return false;
}