AI-Clipboard/lib/utils/screen_adapter.dart
fengshengxiong 50c2738fc5 搭建框架:
1.状态管理、路由、依赖注入
2.屏幕适配
3.日志封装
2024-05-07 18:16:51 +08:00

58 lines
1.0 KiB
Dart

import 'package:flutter_screenutil/flutter_screenutil.dart';
/// [author] fengshengxiong
/// [date] 2024/5/7
/// [description] 屏幕适配器
class ScreenAdapter {
/// 当前设备宽度 dp
static getScreenWidth() {
return ScreenUtil().screenWidth;
}
/// 当前设备高度 dp
static getScreenHeight() {
return ScreenUtil().screenHeight;
}
/// 屏幕宽度的倍数
static sw(num value) {
return value.sw;
}
/// 屏幕高度的倍数
static sh(num value) {
return value.sh;
}
/// 状态栏高度 dp 刘海屏会更高
static getStatusBarHeight() {
return ScreenUtil().statusBarHeight;
}
/// 底部安全区距离 dp
static getBottomSafeAreaHeight() {
return ScreenUtil().bottomBarHeight;
}
/// [ScreenUtil.setWidth]
static w(num value) {
return value.w;
}
/// [ScreenUtil.setHeight]
static h(num value) {
return value.h;
}
/// [ScreenUtil.radius]
static r(num value) {
return value.r;
}
/// [ScreenUtil.setSp]
static sp(num value) {
return value.sp;
}
}