mobile_skt/lib/util/screen_adaper_util.dart

56 lines
1.4 KiB
Dart

import 'package:flutter/material.dart';
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 screenShortDistance() {
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.context?.orientation == Orientation.landscape;
}
static isTablet() {
return ScreenUtil().screenWidth > 650;
}
}