Showing
1 changed file
with
7 additions
and
4 deletions
| @@ -34,6 +34,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; | @@ -34,6 +34,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; | ||
| 34 | 34 | ||
| 35 | ### 初始化设置尺寸 | 35 | ### 初始化设置尺寸 |
| 36 | 在使用之前请设置好设计稿的宽度和高度,传入设计稿的宽度和高度(单位px) | 36 | 在使用之前请设置好设计稿的宽度和高度,传入设计稿的宽度和高度(单位px) |
| 37 | + | ||
| 37 | 一定在MaterialApp的home中的页面设置(即入口文件,只需设置一次),以保证在每次使用之前设置好了适配尺寸: | 38 | 一定在MaterialApp的home中的页面设置(即入口文件,只需设置一次),以保证在每次使用之前设置好了适配尺寸: |
| 38 | 39 | ||
| 39 | ``` | 40 | ``` |
| @@ -43,10 +44,12 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; | @@ -43,10 +44,12 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; | ||
| 43 | 44 | ||
| 44 | ### 使用: | 45 | ### 使用: |
| 45 | 46 | ||
| 46 | -适配尺寸: | 47 | +#### 适配尺寸: |
| 48 | + | ||
| 49 | +传入设计稿的px尺寸: | ||
| 47 | 50 | ||
| 48 | -//传入设计稿的px尺寸: | ||
| 49 | 根据款第适配 width: ScreenUtil().setWidth(540), | 51 | 根据款第适配 width: ScreenUtil().setWidth(540), |
| 52 | + | ||
| 50 | 根据高度适配 height: ScreenUtil().setHeight(200), | 53 | 根据高度适配 height: ScreenUtil().setHeight(200), |
| 51 | 54 | ||
| 52 | **注意** | 55 | **注意** |
| @@ -71,7 +74,7 @@ Container( | @@ -71,7 +74,7 @@ Container( | ||
| 71 | ), | 74 | ), |
| 72 | ``` | 75 | ``` |
| 73 | 76 | ||
| 74 | -适配字体: | 77 | +#### 适配字体: |
| 75 | ``` | 78 | ``` |
| 76 | ScreenUtil().setSp(28) //传入字体大小,根据系统的“字体大小”辅助选项来进行缩放 | 79 | ScreenUtil().setSp(28) //传入字体大小,根据系统的“字体大小”辅助选项来进行缩放 |
| 77 | ScreenUtil().setSp(28,false) //传入字体大小,不会根据系统的“字体大小”辅助选项来进行缩放 | 80 | ScreenUtil().setSp(28,false) //传入字体大小,不会根据系统的“字体大小”辅助选项来进行缩放 |
| @@ -87,7 +90,7 @@ for example: | @@ -87,7 +90,7 @@ for example: | ||
| 87 | 90 | ||
| 88 | ``` | 91 | ``` |
| 89 | 92 | ||
| 90 | -其他相关api: | 93 | +#### 其他相关api: |
| 91 | ``` | 94 | ``` |
| 92 | ScreenUtil.pixelRatio //设备的像素密度 | 95 | ScreenUtil.pixelRatio //设备的像素密度 |
| 93 | ScreenUtil.screenWidth //设备宽度 | 96 | ScreenUtil.screenWidth //设备宽度 |
-
Please register or login to post a comment