checkForUpdates method

Future<ManualUpdateCheckResult> checkForUpdates()

Checks for updates for an explicit user action and returns a typed result.

Implementation

Future<ManualUpdateCheckResult> checkForUpdates() async {
  try {
    await checkVersion();
  } on Object catch (error, stackTrace) {
    _state = UpdateFailed(
      error,
      report: _reportFromStateOrBuild(error),
    );
    notifyListeners();
    return ManualUpdateCheckFailed(error, stackTrace);
  }

  final currentState = state;
  if (currentState is UpdateAvailable) {
    return ManualUpdateCheckAvailable(
      descriptor: currentState.descriptor,
      mandatory: currentState.mandatory,
    );
  }

  if (currentState is UpdateFailed) {
    return ManualUpdateCheckFailed(
      currentState.error,
      StackTrace.current,
    );
  }

  return const ManualUpdateCheckUpToDate();
}