How to check OS version on device from Flutter?
3 answers
There is a plugin for this purpose:
https://github.com/flutter/plugins/tree/master/packages/device_info
+4
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
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');
}
}
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
source to share