Flutter不同终端屏幕适配方案: flutter_screenutil
封装,防止插件更新:
//ScreenAdaper.dart
import 'package:flutter_screenutil/flutter_screenutil.dart';
class ScreenAdaper {
static height(num value) {
return ScreenUtil().setHeight(value);
}
static width(num value) {
return ScreenUtil().setWidth(value);
}
static size(num value) {
return ScreenUtil().setSp(value);
}
static screenWidth() {
return ScreenUtil().screenWidth; // 获取设备物理宽度
}
static screenHeight() {
return ScreenUtil().screenHeight; // 获取设备物理高度
}
}