openInstaller function

Future<void> openInstaller(
  1. File file,
  2. String appName
)

Implementation

Future<void> openInstaller(File file, String appName) async {
  if (file.existsSync()) {
    if (file.path.endsWith("zip")) {
      final outDir = Directory(p.join(p.dirname(file.path), appName));
      file = File(
          outDir.listSync().firstWhere((e) {
            if (Platform.isWindows) {
              return e.path.endsWith("exe");
            } else {
              return true;
            }
          }).path
      );
    }
    await openUri(Uri(path: file.absolute.path, scheme: 'file'));
  } else {
    throw Exception(
      'Installer does not exists, you have to download it first',
    );
  }
}