parseFile static method

File? parseFile(
  1. Object? value, [
  2. File? def
])

Tries to parse a File.

  • Returns def if value is invalid.

Implementation

static File? parseFile(Object? value, [File? def]) {
  if (value == null) return def;

  if (value is File) {
    return value;
  } else if (value is Directory) {
    return File(value.path);
  } else {
    var s = value.toString().trim();
    if (s.isEmpty) return def;

    return File(s);
  }
}