install method

  1. @override
Future<bool> install()
override

Implementation

@override
Future<bool> install() async {
  if (!state.currentStatusIs(status: UpgradeStatus.readyToInstall)) { return false; }
  if (filePath == null) {
    state.updateUpgradeStatus(status: UpgradeStatus.error);
    debugPrint("[UpgradeManager:FileInstaller] Install file doesn't exists at $filePath.");
    return false;
  }

  state.updateUpgradeStatus(status: UpgradeStatus.installing);

  final file = File(filePath!);
  if (!file.existsSync()) {
    state.updateUpgradeStatus(status: UpgradeStatus.error);
    debugPrint("[UpgradeManager.FileInstaller] Install file does not exists, you should download it first.");
    return false;
  }

  final uri = Uri(path: file.absolute.path, scheme: 'file');
  if (!await canLaunchUrl(uri)) {
    state.updateUpgradeStatus(status: UpgradeStatus.error);
    debugPrint("[UpgradeManager:FileInstaller] Cannot install the file at ${uri.path}.");
    return false;
  }
  await launchUrl(uri);

  return true;
}