create method Null safety

Future create(
  1. String distribution,
  2. String filename,
  3. String installPath,
  4. dynamic status(
    1. String
    )
)

Import a WSL distro by name @param distribution: String @param installPath: String distro name or tar file @param filename: String @return Future

Implementation

Future<dynamic> create(String distribution, String filename,
    String installPath, Function(String) status) async {
  if (installPath == '') {
    installPath = defaultPath + distribution;
  }
  mkRootDir(path: installPath);

  // Download
  String downloadPath = '';
  downloadPath = '${defaultPath}distros\\$filename.tar.gz';
  if (distroRootfsLinks[filename] != null &&
      !(await File(downloadPath).exists())) {
    String url = distroRootfsLinks[filename]!;
    // Download file
    try {
      Dio dio = Dio();
      await dio.download(url, downloadPath,
          onReceiveProgress: (int count, int total) {
        status('Step 1: Downloading distro: '
            '${(count / total * 100).toStringAsFixed(0)}%');
      });
    } catch (error) {
      status('Error downloading: $error');
    }
  }

  // Downloaded or extracted
  if (distroRootfsLinks[filename] == null) {
    downloadPath = filename;
  }

  // Create
  ProcessResult results = await Process.run(
      'wsl', ['--import', distribution, installPath, downloadPath]);
  return results;
}