mobile_skt/lib/util/screen_adaper_util.dart

51 lines
1.3 KiB
Dart
Raw Normal View History

import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
/// 屏幕适配类
class ScreenAdaper {
/// 获取 计算后的字体
static double sp(double value) {
return ScreenUtil().setSp(value);
}
/// 获取 计算后的高度
static double height(double value) {
return isLandspace()
? ScreenUtil().setWidth(value)
: ScreenUtil().setHeight(value);
}
/// 获取 计算后的宽度
static double width(double value) {
return isLandspace()
? ScreenUtil().setHeight(value)
: ScreenUtil().setWidth(value);
}
/// 获取 计算后的屏幕高度
static double screenHeight({notAdapt = false}) {
return (isLandspace() && !notAdapt)
? ScreenUtil().screenWidth
: ScreenUtil().screenHeight;
}
/// 获取 计算后的屏幕宽度
static double screenWidth() {
return isLandspace() ? ScreenUtil().screenHeight : ScreenUtil().screenWidth;
}
/// 获取 计算后的radius
static radius(double value) {
return ScreenUtil().radius(value);
}
/// Text 尾部整个单词全部变成省略号的问题
static overflowByChar(String? text) {
return '${text ?? ''}'.replaceAll('', '\u200B');
}
static isLandspace() {
return Get.width > Get.height;
}
}