Skip to content

Commit

Permalink
5.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
李卓原 committed Nov 24, 2021
1 parent 003d429 commit c8927c9
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 25 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,4 @@ doc
# Include when developing application packages.
.lock
coverage*
*.iml
*.lock
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 5.0.1
- support for split screen
- add number.sm (return min(number.sp , number))

# 5.0.0+2
- update readme

Expand Down
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
<td>portrait</td>
<td>screen orientation</td>
</tr>
<tr>
<td>splitScreenMode</td>
<td>bool</td>
<td>true</td>
<td>support for split screen</td>
</tr>
</table>

### Initialize and set the fit size and font size to scale according to the system's "font size" accessibility option
Expand Down Expand Up @@ -150,8 +156,9 @@ class _HomePageState extends State<HomePage> {
```dart
ScreenUtil().setWidth(540) (dart sdk>=2.6 : 540.w) //Adapted to screen width
ScreenUtil().setHeight(200) (dart sdk>=2.6 : 200.h) //Adapted to screen height , under normal circumstances, the height still uses x.w
ScreenUtil().radius(200) (dart sdk>=2.6 : 200.r) //Adapt according to the smaller of width or height
ScreenUtil().radius(200) (dart sdk>=2.6 : 200.r) //Adapt according to the smaller of width or height
ScreenUtil().setSp(24) (dart sdk>=2.6 : 24.sp) //Adapter font
12.sm //return min(12,12.sp)
ScreenUtil().pixelRatio //Device pixel density
ScreenUtil().screenWidth (dart sdk>=2.6 : 1.sw) //Device width
Expand Down
2 changes: 2 additions & 0 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
|designSize|Size|Size(360, 690)|设计稿中设备的尺寸(单位随意,建议dp,但在使用过程中必须保持一致)|
|builder|Widget Function()|Container()|一般返回一个MaterialApp类型的Function()|
|orientation|Orientation|portrait|屏幕方向|
|splitScreenMode|bool|true|支持分屏尺寸|

### 初始化并设置适配尺寸及字体大小是否根据系统的“字体大小”辅助选项来进行缩放
在使用之前请设置好设计稿的宽度和高度,传入设计稿的宽度和高度(单位随意,但在使用过程中必须保持一致)
Expand Down Expand Up @@ -127,6 +128,7 @@ class _HomePageState extends State<HomePage> {
ScreenUtil().setHeight(200) (sdk>=2.6 : 200.h) //根据屏幕高度适配尺寸(一般根据宽度适配即可)
ScreenUtil().radius(200) (sdk>=2.6 : 200.r) //根据宽度或高度中的较小者进行调整
ScreenUtil().setSp(24) (sdk>=2.6 : 24.sp) //适配字体
12.sm // 取12和12.sp中的最小值
ScreenUtil.pixelRatio //设备的像素密度
ScreenUtil.screenWidth (sdk>=2.6 : 1.sw) //设备宽度
Expand Down
29 changes: 29 additions & 0 deletions example/android/example_android.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="android" name="Android">
<configuration>
<option name="ALLOW_USER_CONFIGURATION" value="false" />
<option name="GEN_FOLDER_RELATIVE_PATH_APT" value="/gen" />
<option name="GEN_FOLDER_RELATIVE_PATH_AIDL" value="/gen" />
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/app/src/main/AndroidManifest.xml" />
<option name="RES_FOLDER_RELATIVE_PATH" value="/app/src/main/res" />
<option name="ASSETS_FOLDER_RELATIVE_PATH" value="/app/src/main/assets" />
<option name="LIBS_FOLDER_RELATIVE_PATH" value="/app/src/main/libs" />
<option name="PROGUARD_LOGS_FOLDER_RELATIVE_PATH" value="/app/src/main/proguard_logs" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/app/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/app/src/main/kotlin" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/gen" isTestSource="false" generated="true" />
</content>
<orderEntry type="jdk" jdkName="Android API 29 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Flutter for Android" level="project" />
<orderEntry type="library" name="KotlinJavaRuntime" level="project" />
</component>
</module>
17 changes: 4 additions & 13 deletions lib/screenutil_init.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,15 @@ class ScreenUtilInit extends StatelessWidget {
@override
Widget build(BuildContext context) {
return LayoutBuilder(builder: (_, BoxConstraints constraints) {
if (splitScreenMode) {
constraints = BoxConstraints(
minHeight: constraints.minHeight,
maxHeight: max(constraints.maxHeight, 700),
minWidth: constraints.minWidth,
maxWidth: constraints.maxWidth);
}

if (constraints.maxWidth != 0) {
final Orientation orientation =
constraints.maxWidth > constraints.maxHeight
? Orientation.landscape
: Orientation.portrait;
ScreenUtil.init(
constraints,
orientation: orientation,
designSize: designSize,
);
ScreenUtil.init(constraints,
orientation: orientation,
designSize: designSize,
splitScreenMode: splitScreenMode);
return builder();
}
return Container();
Expand Down
9 changes: 0 additions & 9 deletions lib/size_extension.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,6 @@ extension SizeExtension on num {
///I think that it is good for save size balance on big sizes of screen
double get sm => min(toDouble(), sp);

///[ScreenUtil.setSp]
@Deprecated('please use [sp]')
double get ssp => ScreenUtil().setSp(this);

///[ScreenUtil.setSp]
@Deprecated(
'please use [sp] , and set textScaleFactor: 1.0 , for example: Text("text", textScaleFactor: 1.0)')
double get nsp => ScreenUtil().setSp(this);

///屏幕宽度的倍数
///Multiple of screen width
double get sw => ScreenUtil().screenWidth * this;
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flutter_screenutil
description: A flutter plugin for adapting screen and font size.Guaranteed to look good on different models
version: 5.0.0+2
version: 5.0.1
homepage: https://github.com/OpenFlutter/flutter_screenutil

environment:
Expand Down

0 comments on commit c8927c9

Please sign in to comment.