minAppVersion static method

Version? minAppVersion(
  1. Document response, {
  2. String tagRegExpSource = r'\[\Minimum supported app version\:[\s]*(?<version>[^\s]+)[\s]*\]',
})

Return the minimum app version taken from a tag in the description field from the store response. The tagRegExpSource is used to represent the format of a tag using a regular expression. The format in the description by default is like this: [Minimum supported app version: 1.2.3], which returns the version 1.2.3. If there is no match, it returns null.

Implementation

static Version? minAppVersion(
  Document response, {
  String tagRegExpSource =
      r'\[\Minimum supported app version\:[\s]*(?<version>[^\s]+)[\s]*\]',
}) {
  Version? version;
  try {
    final description = PlayStoreResults.description(response);
    if (description != null) {
      final regExp = RegExp(tagRegExpSource, caseSensitive: false);
      final match = regExp.firstMatch(description);
      final mav = match?.namedGroup('version');

      if (mav != null) {
        try {
          // Verify version string using class Version
          version = Version.parse(mav);
        } on Exception catch (e) {
          print(
              'upgrader: PlayStoreResults.minAppVersion: mav=$mav, tag=$tagRegExpSource, error=$e');
        }
      }
    }
  } on Exception catch (e) {
    print('upgrader.PlayStoreResults.minAppVersion : $e');
  }
  return version;
}