Showing
8 changed files
with
48 additions
and
25 deletions
| @@ -56,6 +56,12 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; | @@ -56,6 +56,12 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; | ||
| 56 | <td>portrait</td> | 56 | <td>portrait</td> |
| 57 | <td>screen orientation</td> | 57 | <td>screen orientation</td> |
| 58 | </tr> | 58 | </tr> |
| 59 | + <tr> | ||
| 60 | + <td>splitScreenMode</td> | ||
| 61 | + <td>bool</td> | ||
| 62 | + <td>true</td> | ||
| 63 | + <td>support for split screen</td> | ||
| 64 | + </tr> | ||
| 59 | </table> | 65 | </table> |
| 60 | 66 | ||
| 61 | ### Initialize and set the fit size and font size to scale according to the system's "font size" accessibility option | 67 | ### Initialize and set the fit size and font size to scale according to the system's "font size" accessibility option |
| @@ -150,8 +156,9 @@ class _HomePageState extends State<HomePage> { | @@ -150,8 +156,9 @@ class _HomePageState extends State<HomePage> { | ||
| 150 | ```dart | 156 | ```dart |
| 151 | ScreenUtil().setWidth(540) (dart sdk>=2.6 : 540.w) //Adapted to screen width | 157 | ScreenUtil().setWidth(540) (dart sdk>=2.6 : 540.w) //Adapted to screen width |
| 152 | ScreenUtil().setHeight(200) (dart sdk>=2.6 : 200.h) //Adapted to screen height , under normal circumstances, the height still uses x.w | 158 | ScreenUtil().setHeight(200) (dart sdk>=2.6 : 200.h) //Adapted to screen height , under normal circumstances, the height still uses x.w |
| 153 | - ScreenUtil().radius(200) (dart sdk>=2.6 : 200.r) //Adapt according to the smaller of width or height | 159 | + ScreenUtil().radius(200) (dart sdk>=2.6 : 200.r) //Adapt according to the smaller of width or height |
| 154 | ScreenUtil().setSp(24) (dart sdk>=2.6 : 24.sp) //Adapter font | 160 | ScreenUtil().setSp(24) (dart sdk>=2.6 : 24.sp) //Adapter font |
| 161 | + 12.sm //return min(12,12.sp) | ||
| 155 | 162 | ||
| 156 | ScreenUtil().pixelRatio //Device pixel density | 163 | ScreenUtil().pixelRatio //Device pixel density |
| 157 | ScreenUtil().screenWidth (dart sdk>=2.6 : 1.sw) //Device width | 164 | ScreenUtil().screenWidth (dart sdk>=2.6 : 1.sw) //Device width |
| @@ -42,6 +42,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; | @@ -42,6 +42,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; | ||
| 42 | |designSize|Size|Size(360, 690)|设计稿中设备的尺寸(单位随意,建议dp,但在使用过程中必须保持一致)| | 42 | |designSize|Size|Size(360, 690)|设计稿中设备的尺寸(单位随意,建议dp,但在使用过程中必须保持一致)| |
| 43 | |builder|Widget Function()|Container()|一般返回一个MaterialApp类型的Function()| | 43 | |builder|Widget Function()|Container()|一般返回一个MaterialApp类型的Function()| |
| 44 | |orientation|Orientation|portrait|屏幕方向| | 44 | |orientation|Orientation|portrait|屏幕方向| |
| 45 | +|splitScreenMode|bool|true|支持分屏尺寸| | ||
| 45 | 46 | ||
| 46 | ### 初始化并设置适配尺寸及字体大小是否根据系统的“字体大小”辅助选项来进行缩放 | 47 | ### 初始化并设置适配尺寸及字体大小是否根据系统的“字体大小”辅助选项来进行缩放 |
| 47 | 在使用之前请设置好设计稿的宽度和高度,传入设计稿的宽度和高度(单位随意,但在使用过程中必须保持一致) | 48 | 在使用之前请设置好设计稿的宽度和高度,传入设计稿的宽度和高度(单位随意,但在使用过程中必须保持一致) |
| @@ -127,6 +128,7 @@ class _HomePageState extends State<HomePage> { | @@ -127,6 +128,7 @@ class _HomePageState extends State<HomePage> { | ||
| 127 | ScreenUtil().setHeight(200) (sdk>=2.6 : 200.h) //根据屏幕高度适配尺寸(一般根据宽度适配即可) | 128 | ScreenUtil().setHeight(200) (sdk>=2.6 : 200.h) //根据屏幕高度适配尺寸(一般根据宽度适配即可) |
| 128 | ScreenUtil().radius(200) (sdk>=2.6 : 200.r) //根据宽度或高度中的较小者进行调整 | 129 | ScreenUtil().radius(200) (sdk>=2.6 : 200.r) //根据宽度或高度中的较小者进行调整 |
| 129 | ScreenUtil().setSp(24) (sdk>=2.6 : 24.sp) //适配字体 | 130 | ScreenUtil().setSp(24) (sdk>=2.6 : 24.sp) //适配字体 |
| 131 | + 12.sm // 取12和12.sp中的最小值 | ||
| 130 | 132 | ||
| 131 | ScreenUtil.pixelRatio //设备的像素密度 | 133 | ScreenUtil.pixelRatio //设备的像素密度 |
| 132 | ScreenUtil.screenWidth (sdk>=2.6 : 1.sw) //设备宽度 | 134 | ScreenUtil.screenWidth (sdk>=2.6 : 1.sw) //设备宽度 |
example/android/example_android.iml
0 → 100644
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | +<module type="JAVA_MODULE" version="4"> | ||
| 3 | + <component name="FacetManager"> | ||
| 4 | + <facet type="android" name="Android"> | ||
| 5 | + <configuration> | ||
| 6 | + <option name="ALLOW_USER_CONFIGURATION" value="false" /> | ||
| 7 | + <option name="GEN_FOLDER_RELATIVE_PATH_APT" value="/gen" /> | ||
| 8 | + <option name="GEN_FOLDER_RELATIVE_PATH_AIDL" value="/gen" /> | ||
| 9 | + <option name="MANIFEST_FILE_RELATIVE_PATH" value="/app/src/main/AndroidManifest.xml" /> | ||
| 10 | + <option name="RES_FOLDER_RELATIVE_PATH" value="/app/src/main/res" /> | ||
| 11 | + <option name="ASSETS_FOLDER_RELATIVE_PATH" value="/app/src/main/assets" /> | ||
| 12 | + <option name="LIBS_FOLDER_RELATIVE_PATH" value="/app/src/main/libs" /> | ||
| 13 | + <option name="PROGUARD_LOGS_FOLDER_RELATIVE_PATH" value="/app/src/main/proguard_logs" /> | ||
| 14 | + </configuration> | ||
| 15 | + </facet> | ||
| 16 | + </component> | ||
| 17 | + <component name="NewModuleRootManager" inherit-compiler-output="true"> | ||
| 18 | + <exclude-output /> | ||
| 19 | + <content url="file://$MODULE_DIR$"> | ||
| 20 | + <sourceFolder url="file://$MODULE_DIR$/app/src/main/java" isTestSource="false" /> | ||
| 21 | + <sourceFolder url="file://$MODULE_DIR$/app/src/main/kotlin" isTestSource="false" /> | ||
| 22 | + <sourceFolder url="file://$MODULE_DIR$/gen" isTestSource="false" generated="true" /> | ||
| 23 | + </content> | ||
| 24 | + <orderEntry type="jdk" jdkName="Android API 29 Platform" jdkType="Android SDK" /> | ||
| 25 | + <orderEntry type="sourceFolder" forTests="false" /> | ||
| 26 | + <orderEntry type="library" name="Flutter for Android" level="project" /> | ||
| 27 | + <orderEntry type="library" name="KotlinJavaRuntime" level="project" /> | ||
| 28 | + </component> | ||
| 29 | +</module> |
| @@ -18,24 +18,15 @@ class ScreenUtilInit extends StatelessWidget { | @@ -18,24 +18,15 @@ class ScreenUtilInit extends StatelessWidget { | ||
| 18 | @override | 18 | @override |
| 19 | Widget build(BuildContext context) { | 19 | Widget build(BuildContext context) { |
| 20 | return LayoutBuilder(builder: (_, BoxConstraints constraints) { | 20 | return LayoutBuilder(builder: (_, BoxConstraints constraints) { |
| 21 | - if (splitScreenMode) { | ||
| 22 | - constraints = BoxConstraints( | ||
| 23 | - minHeight: constraints.minHeight, | ||
| 24 | - maxHeight: max(constraints.maxHeight, 700), | ||
| 25 | - minWidth: constraints.minWidth, | ||
| 26 | - maxWidth: constraints.maxWidth); | ||
| 27 | - } | ||
| 28 | - | ||
| 29 | if (constraints.maxWidth != 0) { | 21 | if (constraints.maxWidth != 0) { |
| 30 | final Orientation orientation = | 22 | final Orientation orientation = |
| 31 | constraints.maxWidth > constraints.maxHeight | 23 | constraints.maxWidth > constraints.maxHeight |
| 32 | ? Orientation.landscape | 24 | ? Orientation.landscape |
| 33 | : Orientation.portrait; | 25 | : Orientation.portrait; |
| 34 | - ScreenUtil.init( | ||
| 35 | - constraints, | ||
| 36 | - orientation: orientation, | ||
| 37 | - designSize: designSize, | ||
| 38 | - ); | 26 | + ScreenUtil.init(constraints, |
| 27 | + orientation: orientation, | ||
| 28 | + designSize: designSize, | ||
| 29 | + splitScreenMode: splitScreenMode); | ||
| 39 | return builder(); | 30 | return builder(); |
| 40 | } | 31 | } |
| 41 | return Container(); | 32 | return Container(); |
| @@ -18,15 +18,6 @@ extension SizeExtension on num { | @@ -18,15 +18,6 @@ extension SizeExtension on num { | ||
| 18 | ///I think that it is good for save size balance on big sizes of screen | 18 | ///I think that it is good for save size balance on big sizes of screen |
| 19 | double get sm => min(toDouble(), sp); | 19 | double get sm => min(toDouble(), sp); |
| 20 | 20 | ||
| 21 | - ///[ScreenUtil.setSp] | ||
| 22 | - @Deprecated('please use [sp]') | ||
| 23 | - double get ssp => ScreenUtil().setSp(this); | ||
| 24 | - | ||
| 25 | - ///[ScreenUtil.setSp] | ||
| 26 | - @Deprecated( | ||
| 27 | - 'please use [sp] , and set textScaleFactor: 1.0 , for example: Text("text", textScaleFactor: 1.0)') | ||
| 28 | - double get nsp => ScreenUtil().setSp(this); | ||
| 29 | - | ||
| 30 | ///屏幕宽度的倍数 | 21 | ///屏幕宽度的倍数 |
| 31 | ///Multiple of screen width | 22 | ///Multiple of screen width |
| 32 | double get sw => ScreenUtil().screenWidth * this; | 23 | double get sw => ScreenUtil().screenWidth * this; |
| 1 | name: flutter_screenutil | 1 | name: flutter_screenutil |
| 2 | description: A flutter plugin for adapting screen and font size.Guaranteed to look good on different models | 2 | description: A flutter plugin for adapting screen and font size.Guaranteed to look good on different models |
| 3 | -version: 5.0.0+2 | 3 | +version: 5.0.1 |
| 4 | homepage: https://github.com/OpenFlutter/flutter_screenutil | 4 | homepage: https://github.com/OpenFlutter/flutter_screenutil |
| 5 | 5 | ||
| 6 | environment: | 6 | environment: |
-
Please register or login to post a comment