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
李卓原
2019-04-17 10:59:22 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
a16e14eba48863d7a0ccecce58ddb3d2f23e2b7e
a16e14eb
1 parent
e779f592
0.5.2
Change the parameter type from int to double
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
30 additions
and
17 deletions
CHANGELOG.md
README.md
README_CN.md
example/pubspec.lock
lib/flutter_screenutil.dart
pubspec.yaml
CHANGELOG.md
View file @
a16e14e
...
...
@@ -35,3 +35,9 @@ setSp(int fontSize, [allowFontScaling = false]) => allowFontScaling
## [0.5.1] - Fix the wrong way of using
It is recommended to use
`ScreenUtil.getInstance()` instead of `ScreenUtil()` , for example: `ScreenUtil.getInstance().setHeight(25)` instead of `ScreenUtil().setHeight(25)`
## [0.5.2] - Change the parameter type from int to double
setWidth,setHeight,setSp.
for example:
you can use setWidth(100) or setWidth(100.0)
\ No newline at end of file
...
...
README.md
View file @
a16e14e
...
...
@@ -21,7 +21,7 @@ dependencies:
flutter:
sdk: flutter
# add flutter_ScreenUtil
flutter_screenutil: ^0.
4
.2
flutter_screenutil: ^0.
5
.2
```
### Add the following imports to your Dart code:
...
...
@@ -33,8 +33,8 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
|Property|Type|Default Value|Description|
|:---|:---|:---|:---|
|width|int|1080px|The width of the device in the design draft, in px|
|height|int|1920px|The height of the device in the design draft, in px|
|width|double|1080px|The width of the device in the design draft, in px|
|height|double|1920px|The height of the device in the design draft, in px|
|allowFontScaling|bool|false|Sets whether the font size is scaled according to the system's "font size" assist option|
### Initialize and set the fit size and font size to scale according to the system's "font size" accessibility option
...
...
README_CN.md
View file @
a16e14e
...
...
@@ -10,7 +10,7 @@
[
README of English
](
https://github.com/OpenFlutter/flutter_ScreenUtil/blob/master/README.md
)
github: https://github.com/OpenFlutter/flutter_
ScreenU
til
github: https://github.com/OpenFlutter/flutter_
screenu
til
csdn博客工具介绍:https://blog.csdn.net/u011272795/article/details/82795477
...
...
@@ -26,7 +26,7 @@ dependencies:
flutter:
sdk: flutter
# 添加依赖
flutter_screenutil: ^0.5.
0
flutter_screenutil: ^0.5.
2
```
### 在每个使用的地方导入包:
...
...
@@ -38,8 +38,8 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
|属性|类型|默认值|描述|
|:---|:---|:---|:---|
|width|int|1080px|设计稿中设备的宽度,单位px|
|height|int|1920px|设计稿中设备的高度,单位px|
|width|double|1080px|设计稿中设备的宽度,单位px|
|height|double|1920px|设计稿中设备的高度,单位px|
|allowFontScaling|bool|false|设置字体大小是否根据系统的“字体大小”辅助选项来进行缩放|
### 初始化并设置适配尺寸及字体大小是否根据系统的“字体大小”辅助选项来进行缩放
...
...
example/pubspec.lock
View file @
a16e14e
...
...
@@ -74,6 +74,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.2"
pedantic:
dependency: transitive
description:
name: pedantic
url: "https://pub.dartlang.org"
source: hosted
version: "1.5.0"
quiver:
dependency: transitive
description:
...
...
@@ -92,7 +99,7 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.
4.1
"
version: "1.
5.5
"
stack_trace:
dependency: transitive
description:
...
...
@@ -120,14 +127,14 @@ packages:
name: term_glyph
url: "https://pub.dartlang.org"
source: hosted
version: "1.
0.1
"
version: "1.
1.0
"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.
1
"
version: "0.2.
2
"
typed_data:
dependency: transitive
description:
...
...
@@ -143,4 +150,4 @@ packages:
source: hosted
version: "2.0.8"
sdks:
dart: ">=2.0.0 <3.0.0"
dart: ">=2.
1.1-dev.
0.0 <3.0.0"
...
...
lib/flutter_screenutil.dart
View file @
a16e14e
...
...
@@ -9,8 +9,8 @@ class ScreenUtil {
static
ScreenUtil
instance
=
new
ScreenUtil
();
//设计稿的设备尺寸修改
int
width
;
int
height
;
double
width
;
double
height
;
bool
allowFontScaling
;
static
MediaQueryData
_mediaQueryData
;
...
...
@@ -77,19 +77,19 @@ class ScreenUtil {
///根据设计稿的设备宽度适配
///高度也根据这个来做适配可以保证不变形
setWidth
(
int
width
)
=>
width
*
scaleWidth
;
setWidth
(
double
width
)
=>
width
*
scaleWidth
;
/// 根据设计稿的设备高度适配
/// 当发现设计稿中的一屏显示的与当前样式效果不符合时,
/// 或者形状有差异时,高度适配建议使用此方法
/// 高度适配主要针对想根据设计稿的一屏展示一样的效果
setHeight
(
int
height
)
=>
height
*
scaleHeight
;
setHeight
(
double
height
)
=>
height
*
scaleHeight
;
///字体大小适配方法
///@param fontSize 传入设计稿上字体的px ,
///@param allowFontScaling 控制字体是否要根据系统的“字体大小”辅助选项来进行缩放。默认值为false。
///@param allowFontScaling Specifies whether fonts should scale to respect Text Size accessibility settings. The default is false.
setSp
(
int
fontSize
)
=>
allowFontScaling
setSp
(
double
fontSize
)
=>
allowFontScaling
?
setWidth
(
fontSize
)
:
setWidth
(
fontSize
)
/
_textScaleFactor
;
}
...
...
pubspec.yaml
View file @
a16e14e
name
:
flutter_screenutil
description
:
A flutter plugin for adapting screen and font size.Guaranteed to look good on different models
version
:
0.5.
1
version
:
0.5.
2
author
:
LiZhuoyuan <zhuoyuan93@gmail.com>
homepage
:
https://github.com/OpenFlutter/flutter_ScreenUtil
...
...
Please
register
or
login
to post a comment