# list method

Future<Instances> list(

1. bool showDocker

)

Returns list of WSL distros

## Implementation

    Future<Instances> list(bool showDocker) async {
      ProcessResult results =
          await Process.run('wsl', ['--list', '--quiet'], stdoutEncoding: null);
      String output = utf8Convert(results.stdout);
      List<String> list = [];
      bool wslInstalled = true;
      // Check if wsl is installed
      if (output.contains('wsl.exe') || output.contains('ProcessException')) {
        wslInstalled = false;
      }
      if (wslInstalled) {
        if (output.contains('ERROR_FILE_NOT_FOUND')) {
          return lastDistroList;
        }
        output.split('\n').forEach((line) {
          var dockerfilter = showDocker
              ? true
              : (!line.startsWith('docker-desktop-data') &&
                  !line.startsWith('docker-desktop'));
          // Filter out docker data
          if (line != '' && dockerfilter) {
            list.add(line);
          }
        });
        List<String> running = await listRunning();
        lastDistroList = Instances(list, running);
        return Instances(list, running);
      } else {
        return Instances(['wslNotInstalled'], []);
      }
    }