How to check OS version on device from Flutter?
Platform.operatingSystem
will tell you if you are working on Android or iOS.
How can I check which OS version of the device I am running on?
+3
DogeLion
source
to share
3 answers
There is a plugin for this purpose:
https://github.com/flutter/plugins/tree/master/packages/device_info
+4
DogeLion
source
to share
You can use platform channels for this task. In native use os, specific code to get the version and resubmit it to flutter. Here's a good example with battery level
+1
German saprykin
source
to share
import 'dart:io' show Platform;
void main() {
// Get the operating system as a string.
String os = Platform.operatingSystem;
// Or, use a predicate getter.
if (Platform.isMacOS) {
print('is a Mac');
} else {
print('is not a Mac');
}
}
Dart SDK> dart: io> Platform
Here is the official article above, and if you want to check if it is IOS or Andriod, you can use:
if (Platform.isIOS) {
print('is a IOS');
} else if (Platform.isAndroid) {
print('is a Andriod');
} else {
}
0
Julien
source
to share