閫傞厤鍚勭灞忓箷
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了閫傞厤鍚勭灞忓箷相关的知识,希望对你有一定的参考价值。
鏍囩锛?a href='http://www.mamicode.com/so/1/mba' title='mba'>mba
util usb 瀹夊叏 璁捐 ret tps ack contexFlutter 涓嶅悓缁堢灞忓箷閫傞厤闂
https://pub.dev/packages/flutter_screenutil
姣忎釜椤甸潰鐨?build 寮曞叆
Widget build(BuildContext context) {
ScreenUtil.init(context, width: 750, height: 1334); // width 璁捐鍥剧殑瀹? height 璁捐鍥剧殑楂?/code>
}ScreenUtil().setHeight(200) // 杩欑鏂瑰紡鍐?楂?bottom top 鐨勫€?/code>
ScreenUtil().setWidth(200) //
杩欑鏂瑰紡鍐?
瀹?
left
right
灏佽濂界殑浠g爜
import 鈥榩ackage:flutter_screenutil/flutter_screenutil.dart鈥?
// 閫傞厤璁惧鍚勭鍒嗚鲸鐜?br />class Screen{
init(context, {width = 750, height = 1334}) {
ScreenUtil.init(context, width: width, height: height); //鍒濆鍖?姣忎釜椤甸潰鐨?build 閮借寮曞叆
}
width(value) {
return ScreenUtil().setWidth(value); //璁剧疆 瀹藉害 left right
}
height(value) {
return ScreenUtil().setHeight(value); //璁剧疆 楂樺害 top bottom
}
screenWidth() {
return ScreenUtil.screenWidth; //璁惧瀹藉害
}
screenHeight() {
return ScreenUtil.screenHeight; //璁惧楂樺害
}
pixelRatio() {
return ScreenUtil.pixelRatio; //璁惧鐨勫儚绱犲瘑搴?br /> }
statusBarHeight() {
return ScreenUtil.statusBarHeight; //鐘舵€佹爮楂樺害 鍒樻捣灞忎細鏇撮珮 鍗曚綅px
}
bottomBarHeight() {
return ScreenUtil.bottomBarHeight; //搴曢儴瀹夊叏鍖鸿窛绂伙紝閫傜敤浜庡叏闈㈠睆涓嬮潰鏈夋寜閿殑
}
scaleWidth() {
return ScreenUtil().scaleWidth; // 瀹為檯瀹藉害鐨刣p涓庤璁$px鐨勬瘮渚?br /> }
scaleHeight() {
return ScreenUtil().scaleHeight; // 瀹為檯楂樺害鐨刣p涓庤璁$px鐨勬瘮渚?br /> }
textScaleFactor() {
return ScreenUtil.textScaleFactor ; //绯荤粺瀛椾綋缂╂斁姣斾緥
}
}
以上是关于閫傞厤鍚勭灞忓箷的主要内容,如果未能解决你的问题,请参考以下文章
viewport銆佸竷灞€瑙嗗彛銆佽瑙夎鍙c€佺悊鎯宠鍙?娣卞叆鐞嗚В