getInstancePath function

SafePath getInstancePath(
  1. String name
)

Get the instance path for the name instance. It will be created if it does not exist.

e.g. C:\WSL2-Distros\ubuntu

Implementation

SafePath getInstancePath(String name) {
  String? instanceLocation = prefs.getString('Path_$name');
  if (instanceLocation != null && instanceLocation.isNotEmpty) {
    // Fix path for older versions
    var safePath = SafePath(instanceLocation);
    prefs.setString('Path_$name', safePath.path);
    return safePath;
  }
  return getDistroPath()
    ..cdUp()
    ..cd(name);
}