operatingSystemVersion property

String get operatingSystemVersion

Implementation

static String get operatingSystemVersion {

  final s = window.navigator.userAgent;

  // Android?
  {
    final regExp = RegExp('Android ([a-zA-Z0-9.-_]+)');
    final match = regExp.firstMatch(s);
    if (match != null) {
      final version = match.group(1) ?? '';
      return version.replaceAll(";", "");
    }
  }

  // iPhone OS?
      {
    final regExp = RegExp('iPhone OS ([a-zA-Z0-9.-_]+) ([a-zA-Z0-9.-_]+)');
    final match = regExp.firstMatch(s);
    if (match != null) {
      final version = (match.group(2) ?? '').replaceAll('_', '.');
      return version.replaceAll(";", "");
    }
  }

  // Mac OS X?
      {
    final regExp = RegExp('Mac OS X ([a-zA-Z0-9.-_]+)');
    final match = regExp.firstMatch(s);
    if (match != null) {
      final version = (match.group(1) ?? '').replaceAll('_', '.');
      return version.replaceAll(";", "");
    }
  }

  // Chrome OS?
      {
    final regExp = RegExp('CrOS ([a-zA-Z0-9.-_]+) ([a-zA-Z0-9.-_]+)');
    final match = regExp.firstMatch(s);
    if (match != null) {
      final version = match.group(2) ?? '';
      return version.replaceAll(";", "");
    }
  }

  // Windows?
      {
    final regExp = RegExp('Windows NT ([a-zA-Z0-9.-_]+)');
    final match = regExp.firstMatch(s);
    if (match != null) {
      final version = (match.group(1) ?? '');
      return version.replaceAll(";", "");
    }
  }

  return "?";
}