// asc
$team->users->sortBy('userProperty');
// desc
$team->users->sortByDesc('userProperty');
会告诉您是否在Android或iOS上运行。
如何查看我正在运行的设备操作系统版本?
答案 0 :(得分:4)
答案 1 :(得分:2)
您可以使用platform channels执行此任务。在本机使用os特定代码来获取版本并重新发送它。这是一个很好的example电池电量
答案 2 :(得分:2)
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');
}
}
这是上面的官方文章,如果你想检查它是IOS或Andriod, 你可以使用:
if (Platform.isIOS) {
print('is a IOS');
} else if (Platform.isAndroid) {
print('is a Andriod');
} else {
}
答案 3 :(得分:1)
人类可读的方式是
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
}