locate method

String? locate({
  1. Map<String, String>? environment,
})

Where it is, or null when it is not installed.

An environment variable FLUTTER3D_<NAME> (the name upper-cased, non-letters as _) names it directly and wins over the search.

Implementation

String? locate({Map<String, String>? environment}) {
  final env = environment ?? Platform.environment;
  final variable =
      'FLUTTER3D_${name.toUpperCase().replaceAll(RegExp('[^A-Z0-9]'), '_')}';
  final named = env[variable];
  if (named != null && named.isNotEmpty && File(named).existsSync()) {
    return named;
  }
  for (final executable in executables) {
    final found = findOnPath(executable, environment: env);
    if (found != null) return found;
  }
  for (final location in knownLocations) {
    if (File(location).existsSync()) return location;
  }
  return null;
}