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-01-11 11:45:04 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
134d76c500bb7c20850d5b80ec7634d51fe250ea
134d76c5
1 parent
3135afde
0.4.5 文档优化
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
15 deletions
README.md
README_CN.md
example/lib/main.dart
lib/flutter_screenutil.dart
README.md
View file @
134d76c
...
...
@@ -27,14 +27,29 @@ dependencies:
import 'package:flutter_screenutil/flutter_screenutil.dart';
```
### Initialize the setup size
### 属性
|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|
|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
Please set the width and height of the design draft before use, the width and height of the design draft (unit px).
Be sure to set the page in the MaterialApp's home(ie the entry file, just set it once) to ensure that the fit size is set before each use:
```
//Set the fit size (fill in the screen size of the device in the design)
//default value : width : 1080px , height:1920px , allowFontScaling:false
ScreenUtil.instance = ScreenUtil()..init(context);
//fill in the screen size of the device in the design
//If the design is based on the size of the iPhone6 (iPhone6 750*1334)
ScreenUtil.instance = ScreenUtil(width: 750, height: 1334)..init(context);
//If you wang to set the font size is scaled according to the system's "font size" assist option
ScreenUtil.instance = ScreenUtil(width: 750, height: 1334, allowFontScaling: true)..init(context);
```
### Use:
...
...
README_CN.md
View file @
134d76c
...
...
@@ -32,12 +32,7 @@ dependencies:
import 'package:flutter_screenutil/flutter_screenutil.dart';
```
### 初始化设置尺寸
在使用之前请设置好设计稿的宽度和高度,传入设计稿的宽度和高度(单位px)
一定在MaterialApp的home中的页面设置(即入口文件,只需设置一次),以保证在每次使用之前设置好了适配尺寸:
#### 属性
### 属性
|属性|类型|默认值|描述|
|:---|:---|:---|:---|
...
...
@@ -45,12 +40,19 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
|height|int|1920px|设计稿中设备的高度,单位px|
|allowFontScaling|bool|false|设置字体大小是否根据系统的“字体大小”辅助选项来进行缩放|
### 初始化并设置适配尺寸及字体大小是否根据系统的“字体大小”辅助选项来进行缩放
在使用之前请设置好设计稿的宽度和高度,传入设计稿的宽度和高度(单位px)
一定在MaterialApp的home中的页面设置(即入口文件,只需设置一次),以保证在每次使用之前设置好了适配尺寸:
```
//设置适配尺寸 (填入设计稿中设备的屏幕尺寸) 假如设计稿是按iPhone6的尺寸设计的(iPhone6 750*1334)
//设置字体大小是否根据系统的“字体大小”辅助选项来进行缩放 , 默认为 false , 字体不随着系统的“字体大小”辅助选项来进行缩放
ScreenUtil.instance = ScreenUtil()..init(context);
ScreenUtil.instance = ScreenUtil(width: 750, height: 1334)..init(context);
ScreenUtil.instance = ScreenUtil(width: 750, height: 1334, allowFontScaling: false)..init(context);
//默认 width : 1080px , height:1920px , allowFontScaling:false
ScreenUtil.instance = ScreenUtil()..init(context);
//填入设计稿中设备的屏幕尺寸 , 假如设计稿是按iPhone6的尺寸设计的(iPhone6 750*1334)
ScreenUtil.instance = ScreenUtil(width: 750, height: 1334)..init(context);
//设置字体大小根据系统的“字体大小”辅助选项来进行缩放,默认为false : 字体不随着系统的“字体大小”辅助选项来进行缩放
ScreenUtil.instance = ScreenUtil(width: 750, height: 1334, allowFontScaling: true)..init(context);
```
...
...
example/lib/main.dart
View file @
134d76c
...
...
@@ -32,6 +32,7 @@ class _MyHomePageState extends State<MyHomePage> {
Widget
build
(
BuildContext
context
)
{
///Set the fit size (fill in the screen size of the device in the design) If the design is based on the size of the iPhone6 (iPhone6 750*1334)
ScreenUtil
.
instance
=
ScreenUtil
(
width:
750
,
height:
1334
)..
init
(
context
);
print
(
'Device width:
${ScreenUtil.screenWidth}
'
);
//Device width
print
(
'Device height:
${ScreenUtil.screenHeight}
'
);
//Device height
print
(
...
...
lib/flutter_screenutil.dart
View file @
134d76c
...
...
@@ -24,8 +24,8 @@ class ScreenUtil {
static
double
_textScaleFactor
;
ScreenUtil
({
this
.
width
,
this
.
height
,
this
.
width
=
1080
,
this
.
height
=
1920
,
this
.
allowFontScaling
=
false
,
});
...
...
Please
register
or
login
to post a comment