Files
record-tool/lib/core/utils/device_utils.dart
林锋 02c1c87b46 1. 升级依赖版本
2. 解决运行项目警告日志问题
3. 优化代码
2026-06-04 13:55:33 +08:00

32 lines
911 B
Dart

import 'dart:io';
import 'package:flutter/material.dart';
import 'package:recording_tool/core/platform/app_platform_info.dart';
class DeviceUtils {
DeviceUtils._();
static double screenWidth(BuildContext context) =>
MediaQuery.sizeOf(context).width;
static double screenHeight(BuildContext context) =>
MediaQuery.sizeOf(context).height;
static double topSafePadding(BuildContext context) =>
MediaQuery.paddingOf(context).top;
static double bottomSafePadding(BuildContext context) =>
MediaQuery.paddingOf(context).bottom;
static Future<bool> isPhysicalDevice() async {
return (await AppPlatformInfo.deviceInfo()).isPhysicalDevice;
}
static Future<Map<String, String>> deviceInfo() async {
if (!Platform.isAndroid && !Platform.isIOS) {
return {'platform': Platform.operatingSystem};
}
return (await AppPlatformInfo.deviceInfo()).values;
}
}