我一直在尝试获取Android设备版本(例如11、12)。我一直在尝试只获取数字
这就是我到目前为止所做的
void checkVersion(){
print(Platform.operatingSystemVersion); // it prints "sdk_gphone64_arm64-userdebug 12 S2B2.211203.006 8015633 dev-keys"
// I'm able to fetch the version number by splitting the string
// but the problem is that format of above string will vary by
// operating system, so not suitable for parsing
int platformVersion = int.parse(Platform.operatingSystemVersion.split(' ')[1]); it prints '12'
}
Run Code Online (Sandbox Code Playgroud)