exists method

Future<bool> exists(
  1. String filePath, {
  2. dynamic sudo = false,
})

Check if filePath exists If sudo is true, the file will be checked with sudo permissions

Implementation

Future<bool> exists(String filePath, {sudo = false}) async {
  try {
    if (Platform.isWindows) {
      return await File(filePath).exists();
    }

    final result = await simple('test', ['-e', filePath], sudo: sudo);
    return result.exitCode == 0;
  } catch (e) {
    return false;
  }
}