Air*_*ark 78
将此插件添加到您的 pubspec device_info
人类可读的方式是
if (Platform.isAndroid) {
var androidInfo = await DeviceInfoPlugin().androidInfo;
var release = androidInfo.version.release;
var sdkInt = androidInfo.version.sdkInt;
var manufacturer = androidInfo.manufacturer;
var model = androidInfo.model;
print('Android $release (SDK $sdkInt), $manufacturer $model');
// Android 9 (SDK 28), Xiaomi Redmi Note 7
}
if (Platform.isIOS) {
var iosInfo = await DeviceInfoPlugin().iosInfo;
var systemName = iosInfo.systemName;
var version = iosInfo.systemVersion;
var name = iosInfo.name;
var model = iosInfo.model;
print('$systemName $version, $name $model');
// iOS 13.1, iPhone 11 Pro Max iPhone
}
Run Code Online (Sandbox Code Playgroud)
小智 7
您可以使用dart:io
import 'dart:io' show Platform;
String osVersion = Platform.operatingSystemVersion;
Run Code Online (Sandbox Code Playgroud)
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');
}
}
Run Code Online (Sandbox Code Playgroud)
这是上面的官方文章,如果你要检查是IOS还是Andriod,可以使用:
if (Platform.isIOS) {
print('is a IOS');
} else if (Platform.isAndroid) {
print('is a Andriod');
} else {
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8583 次 |
| 最近记录: |