version method

String? version(
  1. Document response
)

Return field version from Play Store results.

Implementation

String? version(Document response) {
  String? version;
  try {
    final additionalInfoElements = response.getElementsByClassName('hAyfc');
    final versionElement = additionalInfoElements.firstWhere(
      (elm) => elm.querySelector('.BgcNfc')!.text == 'Current Version',
    );
    final storeVersion = versionElement.querySelector('.htlgb')!.text;
    // storeVersion might be: 'Varies with device', which is not a valid version.
    version = Version.parse(storeVersion).toString();
  } catch (e) {
    return redesignedVersion(response);
  }

  return version;
}