checkForUpdate method

Future<void> checkForUpdate()

Implementation

Future<void> checkForUpdate() async {
  try {
    final hasConnection = await NetworkController().checkConnection();

    if (!hasConnection) {
      return;
    }

    final Package = await PackageInfo.fromPlatform();
    final currentVersion = Package.version;

    final hasUpdate = await CloudFireStoreRepo().isUpdateAvailable(
      currentVersion,
    );

    if (hasUpdate) {
      emit(AppUpdateAvailable());
    } else {
      emit(AppUpToDate());
    }
  } catch (e) {
    throw Exception('Failed to check for update: $e');
  }
}