Toggle navigation
Toggle navigation
This project
Loading...
Sign in
flutter_package
/
flutter_screenutil
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
李卓原
2021-11-24 11:18:19 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
c8927c9c941ce47dd07c5950666511eb6448f900
c8927c9c
1 parent
003d429b
5.0.1
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
48 additions
and
25 deletions
.gitignore
CHANGELOG.md
README.md
README_CN.md
example/android/example_android.iml
lib/screenutil_init.dart
lib/size_extension.dart
pubspec.yaml
.gitignore
View file @
c8927c9
...
...
@@ -19,5 +19,4 @@ doc
# Include when developing application packages.
.lock
coverage*
*.iml
*.lock
...
...
CHANGELOG.md
View file @
c8927c9
# 5.0.1
-
support for split screen
-
add number.sm (return min(number.sp , number))
# 5.0.0+2
-
update readme
...
...
README.md
View file @
c8927c9
...
...
@@ -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
...
...
@@ -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
...
...
README_CN.md
View file @
c8927c9
...
...
@@ -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|支持分屏尺寸|
### 初始化并设置适配尺寸及字体大小是否根据系统的“字体大小”辅助选项来进行缩放
在使用之前请设置好设计稿的宽度和高度,传入设计稿的宽度和高度(单位随意,但在使用过程中必须保持一致)
...
...
@@ -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
)
//设备宽度
...
...
example/android/example_android.iml
0 → 100644
View file @
c8927c9
<?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>
...
...
lib/screenutil_init.dart
View file @
c8927c9
...
...
@@ -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
();
...
...
lib/size_extension.dart
View file @
c8927c9
...
...
@@ -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
;
...
...
pubspec.yaml
View file @
c8927c9
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
:
...
...
Please
register
or
login
to post a comment