isValidPath static method

bool isValidPath(
  1. String path
)

Must start with /, not end with /, no spaces/backslashes. Empty is allowed (level2's default path).

Implementation

static bool isValidPath(String path) {
  if (path.isEmpty) return true;

  return path.startsWith('/') &&
      !path.endsWith('/') &&
      !path.contains(' ') &&
      !path.contains(r'\') &&
      path.length > 1;
}