operatingSystemVersion top-level property
String
get
operatingSystemVersion
General Library Documentation Undocument By General Corporation & Global Corporation & General Developer
Implementation
String get operatingSystemVersion {
final userAgent = web.window.navigator.userAgent;
// Android?
{
final regExp = RegExp('Android ([a-zA-Z0-9.-_]+)');
final match = regExp.firstMatch(userAgent);
if (match != null) {
final version = match.group(1) ?? '';
return version;
}
}
// iPhone OS?
{
final regExp = RegExp('iPhone OS ([a-zA-Z0-9.-_]+) ([a-zA-Z0-9.-_]+)');
final match = regExp.firstMatch(userAgent);
if (match != null) {
final version = (match.group(2) ?? '').replaceAll('_', '.');
return version;
}
}
// Mac OS X?
{
final regExp = RegExp('Mac OS X ([a-zA-Z0-9.-_]+)');
final match = regExp.firstMatch(userAgent);
if (match != null) {
final version = (match.group(1) ?? '').replaceAll('_', '.');
return version;
}
}
// Chrome OS?
{
final regExp = RegExp('CrOS ([a-zA-Z0-9.-_]+) ([a-zA-Z0-9.-_]+)');
final match = regExp.firstMatch(userAgent);
if (match != null) {
final version = match.group(2) ?? '';
return version;
}
}
// Windows NT?
{
final regExp = RegExp('Windows NT ([a-zA-Z0-9.-_]+)');
final match = regExp.firstMatch(userAgent);
if (match != null) {
final version = (match.group(1) ?? '');
return version;
}
}
return '';
}