Skip to content

Commit

Permalink
修改release无效的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
lizhuoyuan committed Sep 29, 2018
1 parent 7f76f59 commit eb6f740
Show file tree
Hide file tree
Showing 9 changed files with 786 additions and 623 deletions.
117 changes: 10 additions & 107 deletions .idea/libraries/Dart_Packages.xml

Large diffs are not rendered by default.

299 changes: 265 additions & 34 deletions .idea/workspace.xml

Large diffs are not rendered by default.

110 changes: 55 additions & 55 deletions .packages
Original file line number Diff line number Diff line change
@@ -1,56 +1,56 @@
# Generated by pub on 2018-09-21 00:18:30.075689.
analyzer:file:///d:/flutter/.pub-cache/hosted/pub.flutter-io.cn/analyzer-0.32.4/lib/
args:file:///d:/flutter/.pub-cache/hosted/pub.flutter-io.cn/args-1.5.0/lib/
async:file:///d:/flutter/.pub-cache/hosted/pub.flutter-io.cn/async-2.0.8/lib/
boolean_selector:file:///d:/flutter/.pub-cache/hosted/pub.flutter-io.cn/boolean_selector-1.0.4/lib/
charcode:file:///d:/flutter/.pub-cache/hosted/pub.flutter-io.cn/charcode-1.1.2/lib/
collection:file:///d:/flutter/.pub-cache/hosted/pub.flutter-io.cn/collection-1.14.11/lib/
convert:file:///d:/flutter/.pub-cache/hosted/pub.flutter-io.cn/convert-2.0.2/lib/
crypto:file:///d:/flutter/.pub-cache/hosted/pub.flutter-io.cn/crypto-2.0.6/lib/
csslib:file:///d:/flutter/.pub-cache/hosted/pub.flutter-io.cn/csslib-0.14.5/lib/
flutter:file:///d:/flutter/packages/flutter/lib/
flutter_test:file:///d:/flutter/packages/flutter_test/lib/
front_end:file:///d:/flutter/.pub-cache/hosted/pub.flutter-io.cn/front_end-0.1.4/lib/
glob:file:///d:/flutter/.pub-cache/hosted/pub.flutter-io.cn/glob-1.1.7/lib/
html:file:///d:/flutter/.pub-cache/hosted/pub.flutter-io.cn/html-0.13.3+3/lib/
http:file:///d:/flutter/.pub-cache/hosted/pub.flutter-io.cn/http-0.11.3+17/lib/
http_multi_server:file:///d:/flutter/.pub-cache/hosted/pub.flutter-io.cn/http_multi_server-2.0.5/lib/
http_parser:file:///d:/flutter/.pub-cache/hosted/pub.flutter-io.cn/http_parser-3.1.3/lib/
io:file:///d:/flutter/.pub-cache/hosted/pub.flutter-io.cn/io-0.3.3/lib/
js:file:///d:/flutter/.pub-cache/hosted/pub.flutter-io.cn/js-0.6.1+1/lib/
json_rpc_2:file:///d:/flutter/.pub-cache/hosted/pub.flutter-io.cn/json_rpc_2-2.0.9/lib/
kernel:file:///d:/flutter/.pub-cache/hosted/pub.flutter-io.cn/kernel-0.3.4/lib/
logging:file:///d:/flutter/.pub-cache/hosted/pub.flutter-io.cn/logging-0.11.3+2/lib/
matcher:file:///d:/flutter/.pub-cache/hosted/pub.flutter-io.cn/matcher-0.12.3+1/lib/
meta:file:///d:/flutter/.pub-cache/hosted/pub.flutter-io.cn/meta-1.1.6/lib/
mime:file:///d:/flutter/.pub-cache/hosted/pub.flutter-io.cn/mime-0.9.6+2/lib/
multi_server_socket:file:///d:/flutter/.pub-cache/hosted/pub.flutter-io.cn/multi_server_socket-1.0.2/lib/
node_preamble:file:///d:/flutter/.pub-cache/hosted/pub.flutter-io.cn/node_preamble-1.4.4/lib/
package_config:file:///d:/flutter/.pub-cache/hosted/pub.flutter-io.cn/package_config-1.0.5/lib/
package_resolver:file:///d:/flutter/.pub-cache/hosted/pub.flutter-io.cn/package_resolver-1.0.4/lib/
path:file:///d:/flutter/.pub-cache/hosted/pub.flutter-io.cn/path-1.6.2/lib/
plugin:file:///d:/flutter/.pub-cache/hosted/pub.flutter-io.cn/plugin-0.2.0+3/lib/
pool:file:///d:/flutter/.pub-cache/hosted/pub.flutter-io.cn/pool-1.3.6/lib/
pub_semver:file:///d:/flutter/.pub-cache/hosted/pub.flutter-io.cn/pub_semver-1.4.2/lib/
quiver:file:///d:/flutter/.pub-cache/hosted/pub.flutter-io.cn/quiver-2.0.0+1/lib/
shelf:file:///d:/flutter/.pub-cache/hosted/pub.flutter-io.cn/shelf-0.7.3+3/lib/
shelf_packages_handler:file:///d:/flutter/.pub-cache/hosted/pub.flutter-io.cn/shelf_packages_handler-1.0.4/lib/
shelf_static:file:///d:/flutter/.pub-cache/hosted/pub.flutter-io.cn/shelf_static-0.2.8/lib/
shelf_web_socket:file:///d:/flutter/.pub-cache/hosted/pub.flutter-io.cn/shelf_web_socket-0.2.2+4/lib/
sky_engine:file:///d:/flutter/bin/cache/pkg/sky_engine/lib/
source_map_stack_trace:file:///d:/flutter/.pub-cache/hosted/pub.flutter-io.cn/source_map_stack_trace-1.1.5/lib/
source_maps:file:///d:/flutter/.pub-cache/hosted/pub.flutter-io.cn/source_maps-0.10.7/lib/
source_span:file:///d:/flutter/.pub-cache/hosted/pub.flutter-io.cn/source_span-1.4.1/lib/
stack_trace:file:///d:/flutter/.pub-cache/hosted/pub.flutter-io.cn/stack_trace-1.9.3/lib/
stream_channel:file:///d:/flutter/.pub-cache/hosted/pub.flutter-io.cn/stream_channel-1.6.8/lib/
string_scanner:file:///d:/flutter/.pub-cache/hosted/pub.flutter-io.cn/string_scanner-1.0.4/lib/
term_glyph:file:///d:/flutter/.pub-cache/hosted/pub.flutter-io.cn/term_glyph-1.0.1/lib/
test:file:///d:/flutter/.pub-cache/hosted/pub.flutter-io.cn/test-1.3.0/lib/
typed_data:file:///d:/flutter/.pub-cache/hosted/pub.flutter-io.cn/typed_data-1.1.6/lib/
utf:file:///d:/flutter/.pub-cache/hosted/pub.flutter-io.cn/utf-0.9.0+5/lib/
vector_math:file:///d:/flutter/.pub-cache/hosted/pub.flutter-io.cn/vector_math-2.0.8/lib/
vm_service_client:file:///d:/flutter/.pub-cache/hosted/pub.flutter-io.cn/vm_service_client-0.2.6/lib/
watcher:file:///d:/flutter/.pub-cache/hosted/pub.flutter-io.cn/watcher-0.9.7+10/lib/
web_socket_channel:file:///d:/flutter/.pub-cache/hosted/pub.flutter-io.cn/web_socket_channel-1.0.9/lib/
yaml:file:///d:/flutter/.pub-cache/hosted/pub.flutter-io.cn/yaml-2.1.15/lib/
# Generated by pub on 2018-09-29 11:16:33.432789.
analyzer:file:///C:/Users/Frank/AppData/Roaming/Pub/Cache/hosted/pub.flutter-io.cn/analyzer-0.32.4/lib/
args:file:///C:/Users/Frank/AppData/Roaming/Pub/Cache/hosted/pub.flutter-io.cn/args-1.5.0/lib/
async:file:///C:/Users/Frank/AppData/Roaming/Pub/Cache/hosted/pub.flutter-io.cn/async-2.0.8/lib/
boolean_selector:file:///C:/Users/Frank/AppData/Roaming/Pub/Cache/hosted/pub.flutter-io.cn/boolean_selector-1.0.4/lib/
charcode:file:///C:/Users/Frank/AppData/Roaming/Pub/Cache/hosted/pub.flutter-io.cn/charcode-1.1.2/lib/
collection:file:///C:/Users/Frank/AppData/Roaming/Pub/Cache/hosted/pub.flutter-io.cn/collection-1.14.11/lib/
convert:file:///C:/Users/Frank/AppData/Roaming/Pub/Cache/hosted/pub.flutter-io.cn/convert-2.0.2/lib/
crypto:file:///C:/Users/Frank/AppData/Roaming/Pub/Cache/hosted/pub.flutter-io.cn/crypto-2.0.6/lib/
csslib:file:///C:/Users/Frank/AppData/Roaming/Pub/Cache/hosted/pub.flutter-io.cn/csslib-0.14.5/lib/
flutter:file:///D:/flutter/packages/flutter/lib/
flutter_test:file:///D:/flutter/packages/flutter_test/lib/
front_end:file:///C:/Users/Frank/AppData/Roaming/Pub/Cache/hosted/pub.flutter-io.cn/front_end-0.1.4/lib/
glob:file:///C:/Users/Frank/AppData/Roaming/Pub/Cache/hosted/pub.flutter-io.cn/glob-1.1.7/lib/
html:file:///C:/Users/Frank/AppData/Roaming/Pub/Cache/hosted/pub.flutter-io.cn/html-0.13.3+3/lib/
http:file:///C:/Users/Frank/AppData/Roaming/Pub/Cache/hosted/pub.flutter-io.cn/http-0.11.3+17/lib/
http_multi_server:file:///C:/Users/Frank/AppData/Roaming/Pub/Cache/hosted/pub.flutter-io.cn/http_multi_server-2.0.5/lib/
http_parser:file:///C:/Users/Frank/AppData/Roaming/Pub/Cache/hosted/pub.flutter-io.cn/http_parser-3.1.3/lib/
io:file:///C:/Users/Frank/AppData/Roaming/Pub/Cache/hosted/pub.flutter-io.cn/io-0.3.3/lib/
js:file:///C:/Users/Frank/AppData/Roaming/Pub/Cache/hosted/pub.flutter-io.cn/js-0.6.1+1/lib/
json_rpc_2:file:///C:/Users/Frank/AppData/Roaming/Pub/Cache/hosted/pub.flutter-io.cn/json_rpc_2-2.0.9/lib/
kernel:file:///C:/Users/Frank/AppData/Roaming/Pub/Cache/hosted/pub.flutter-io.cn/kernel-0.3.4/lib/
logging:file:///C:/Users/Frank/AppData/Roaming/Pub/Cache/hosted/pub.flutter-io.cn/logging-0.11.3+2/lib/
matcher:file:///C:/Users/Frank/AppData/Roaming/Pub/Cache/hosted/pub.flutter-io.cn/matcher-0.12.3+1/lib/
meta:file:///C:/Users/Frank/AppData/Roaming/Pub/Cache/hosted/pub.flutter-io.cn/meta-1.1.6/lib/
mime:file:///C:/Users/Frank/AppData/Roaming/Pub/Cache/hosted/pub.flutter-io.cn/mime-0.9.6+2/lib/
multi_server_socket:file:///C:/Users/Frank/AppData/Roaming/Pub/Cache/hosted/pub.flutter-io.cn/multi_server_socket-1.0.2/lib/
node_preamble:file:///C:/Users/Frank/AppData/Roaming/Pub/Cache/hosted/pub.flutter-io.cn/node_preamble-1.4.4/lib/
package_config:file:///C:/Users/Frank/AppData/Roaming/Pub/Cache/hosted/pub.flutter-io.cn/package_config-1.0.5/lib/
package_resolver:file:///C:/Users/Frank/AppData/Roaming/Pub/Cache/hosted/pub.flutter-io.cn/package_resolver-1.0.4/lib/
path:file:///C:/Users/Frank/AppData/Roaming/Pub/Cache/hosted/pub.flutter-io.cn/path-1.6.2/lib/
plugin:file:///C:/Users/Frank/AppData/Roaming/Pub/Cache/hosted/pub.flutter-io.cn/plugin-0.2.0+3/lib/
pool:file:///C:/Users/Frank/AppData/Roaming/Pub/Cache/hosted/pub.flutter-io.cn/pool-1.3.6/lib/
pub_semver:file:///C:/Users/Frank/AppData/Roaming/Pub/Cache/hosted/pub.flutter-io.cn/pub_semver-1.4.2/lib/
quiver:file:///C:/Users/Frank/AppData/Roaming/Pub/Cache/hosted/pub.flutter-io.cn/quiver-2.0.0+1/lib/
shelf:file:///C:/Users/Frank/AppData/Roaming/Pub/Cache/hosted/pub.flutter-io.cn/shelf-0.7.3+3/lib/
shelf_packages_handler:file:///C:/Users/Frank/AppData/Roaming/Pub/Cache/hosted/pub.flutter-io.cn/shelf_packages_handler-1.0.4/lib/
shelf_static:file:///C:/Users/Frank/AppData/Roaming/Pub/Cache/hosted/pub.flutter-io.cn/shelf_static-0.2.8/lib/
shelf_web_socket:file:///C:/Users/Frank/AppData/Roaming/Pub/Cache/hosted/pub.flutter-io.cn/shelf_web_socket-0.2.2+4/lib/
sky_engine:file:///D:/flutter/bin/cache/pkg/sky_engine/lib/
source_map_stack_trace:file:///C:/Users/Frank/AppData/Roaming/Pub/Cache/hosted/pub.flutter-io.cn/source_map_stack_trace-1.1.5/lib/
source_maps:file:///C:/Users/Frank/AppData/Roaming/Pub/Cache/hosted/pub.flutter-io.cn/source_maps-0.10.7/lib/
source_span:file:///C:/Users/Frank/AppData/Roaming/Pub/Cache/hosted/pub.flutter-io.cn/source_span-1.4.1/lib/
stack_trace:file:///C:/Users/Frank/AppData/Roaming/Pub/Cache/hosted/pub.flutter-io.cn/stack_trace-1.9.3/lib/
stream_channel:file:///C:/Users/Frank/AppData/Roaming/Pub/Cache/hosted/pub.flutter-io.cn/stream_channel-1.6.8/lib/
string_scanner:file:///C:/Users/Frank/AppData/Roaming/Pub/Cache/hosted/pub.flutter-io.cn/string_scanner-1.0.4/lib/
term_glyph:file:///C:/Users/Frank/AppData/Roaming/Pub/Cache/hosted/pub.flutter-io.cn/term_glyph-1.0.1/lib/
test:file:///C:/Users/Frank/AppData/Roaming/Pub/Cache/hosted/pub.flutter-io.cn/test-1.3.0/lib/
typed_data:file:///C:/Users/Frank/AppData/Roaming/Pub/Cache/hosted/pub.flutter-io.cn/typed_data-1.1.6/lib/
utf:file:///C:/Users/Frank/AppData/Roaming/Pub/Cache/hosted/pub.flutter-io.cn/utf-0.9.0+5/lib/
vector_math:file:///C:/Users/Frank/AppData/Roaming/Pub/Cache/hosted/pub.flutter-io.cn/vector_math-2.0.8/lib/
vm_service_client:file:///C:/Users/Frank/AppData/Roaming/Pub/Cache/hosted/pub.flutter-io.cn/vm_service_client-0.2.6/lib/
watcher:file:///C:/Users/Frank/AppData/Roaming/Pub/Cache/hosted/pub.flutter-io.cn/watcher-0.9.7+10/lib/
web_socket_channel:file:///C:/Users/Frank/AppData/Roaming/Pub/Cache/hosted/pub.flutter-io.cn/web_socket_channel-1.0.9/lib/
yaml:file:///C:/Users/Frank/AppData/Roaming/Pub/Cache/hosted/pub.flutter-io.cn/yaml-2.1.15/lib/
flutter_screenutil:lib/
23 changes: 16 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
### 初始化设置尺寸
在使用之前请设置好设计稿的宽度和高度,传入设计稿的宽度和高度(单位px)
如果不设置则使用默认尺寸,默认为1080*1920
推荐在项目入口中设置,以保证在每次使用之前设置好了适配尺寸:
一定在MaterialApp的home中的页面设置,以保证在每次使用之前设置好了适配尺寸:

```
ScreenUtil.instance = new ScreenUtil(width: 360, height: 720);
//设置适配尺寸 (填入设计稿中设备的屏幕尺寸) 假如设计稿是按iPhone6的尺寸设计的(iPhone6 750*1334)
ScreenUtil.instance = ScreenUtil(width: 750, height: 1334)..init(context);
```

### 使用:
Expand All @@ -57,13 +58,23 @@ height: ScreenUtil().setHeight(200),
```

```
import 'package:flutter_app/ScreenUtil.dart'; //导入
//导入
import 'package:flutter_screenutil/flutter_screenutil.dart';
...
@override
@override
Widget build(BuildContext context) {
//设置适配尺寸 (填入设计稿中设备的屏幕尺寸) 假如设计稿是按iPhone6的尺寸设计的(iPhone6 750*1334)
ScreenUtil.instance = ScreenUtil(width: 750, height: 1334)..init(context);
print('设备宽度:${ScreenUtil.screenWidth}'); //设备宽度
print('设备高度:${ScreenUtil.screenHeight}'); //设备高度
print('设备的像素密度:${ScreenUtil.pixelRatio}'); //设备的像素密度
print('底部安全区距离:${ScreenUtil.bottomBarHeight}'); //底部安全区距离,适用于全面屏下面有按键的
print('状态栏高度:${ScreenUtil.statusBarHeight}px'); //状态栏高度 刘海屏会更高
print('宽度相对于设计稿放大的倍数:${ScreenUtil().scaleWidth}'); //宽度相对于设计稿放大的倍数
print('高度相对于设计稿放大的倍数:${ScreenUtil().scaleHeight}'); //高度相对于设计稿放大的倍数
return new Scaffold(
appBar: new AppBar(
title: new Text(widget.title),
Expand Down Expand Up @@ -96,8 +107,6 @@ import 'package:flutter_app/ScreenUtil.dart'; //导入
Text('设备的像素密度:${ScreenUtil.pixelRatio}'),
Text('底部安全区距离:${ScreenUtil.bottomBarHeight}px'),
Text('状态栏高度:${ScreenUtil.statusBarHeight}px'),
Text('宽度相对于设计稿放大的倍数:${ScreenUtil().scaleWidth}'),
Text('高度相对于设计稿放大的倍数:${ScreenUtil().scaleHeight}'),
],
),
),
Expand Down
17 changes: 7 additions & 10 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
//假如设计稿是按iPhone6的尺寸设计的(iPhone6 750*1334)
ScreenUtil.instance = new ScreenUtil(width: 750, height: 1334);

return new MaterialApp(
title: 'Flutter Demo',
theme: new ThemeData(
Expand All @@ -34,18 +31,20 @@ class _MyHomePageState extends State<MyHomePage> {
void initState() {
// TODO: implement initState
super.initState();
print('设备的像素密度:${ScreenUtil.pixelRatio}'); //设备的像素密度
}

@override
Widget build(BuildContext context) {
//设置适配尺寸 (填入设计稿中设备的屏幕尺寸) 假如设计稿是按iPhone6的尺寸设计的(iPhone6 750*1334)
ScreenUtil.instance = ScreenUtil(width: 750, height: 1334)..init(context);
print('设备宽度:${ScreenUtil.screenWidth}'); //设备宽度
print('设备高度:${ScreenUtil.screenHeight}'); //设备高度
print('设备的像素密度:${ScreenUtil.pixelRatio}'); //设备的像素密度
print('底部安全区距离:${ScreenUtil.bottomBarHeight}'); //底部安全区距离,适用于全面屏下面有按键的
print('状态栏高度:${ScreenUtil.statusBarHeight}px'); //状态栏高度 刘海屏会更高

print('宽度相对于设计稿放大的倍数:${ScreenUtil().scaleWidth}'); //宽度相对于设计稿放大的倍数
print('高度相对于设计稿放大的倍数:${ScreenUtil().scaleHeight}'); //高度相对于设计稿放大的倍数
}

@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text(widget.title),
Expand Down Expand Up @@ -78,8 +77,6 @@ class _MyHomePageState extends State<MyHomePage> {
Text('设备的像素密度:${ScreenUtil.pixelRatio}'),
Text('底部安全区距离:${ScreenUtil.bottomBarHeight}px'),
Text('状态栏高度:${ScreenUtil.statusBarHeight}px'),
Text('宽度相对于设计稿放大的倍数:${ScreenUtil().scaleWidth}'),
Text('高度相对于设计稿放大的倍数:${ScreenUtil().scaleHeight}'),
],
),
),
Expand Down
9 changes: 8 additions & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.14.11"
common_utils:
dependency: "direct main"
description:
name: common_utils
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.0.2"
convert:
dependency: transitive
description:
Expand Down Expand Up @@ -81,7 +88,7 @@ packages:
description:
path: "."
ref: HEAD
resolved-ref: "94af1bacf4c9f89461a592b26fac8eceb1df3343"
resolved-ref: "62d8b7d3a3cc4323eca1682166d7aee2890b1468"
url: "git://github.com/lizhuoyuan/flutter_screenUtil"
source: git
version: "0.1.0"
Expand Down
1 change: 1 addition & 0 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ dependencies:
flutter_screenutil:
git:
url: git://github.com/lizhuoyuan/flutter_screenUtil
common_utils: ^1.0.2
dev_dependencies:
flutter_test:
sdk: flutter
Expand Down
79 changes: 47 additions & 32 deletions lib/flutter_screenutil.dart
Original file line number Diff line number Diff line change
@@ -1,59 +1,74 @@
/*
* Created by 李卓原 on 2018/9/20.
* Created by 李卓原 on 2018/9/29.
* email: zhuoyuan93@gmail.com
* 设计稿设备尺寸默认为 1080 * 1920 px
*/

import 'dart:ui';
import 'package:flutter/material.dart';

class ScreenUtil {
//请修改成你的设计稿的尺寸
static ScreenUtil instance = new ScreenUtil(width: 1080, height: 1920);
static ScreenUtil instance = new ScreenUtil();

//设计稿的设备尺寸修改
int designWidth;
int designHeight;
int _designWidth;

int _designHeight;

static MediaQueryData _mediaQueryData;
static double _screenWidth;
static double _screenHeight;
static double _pixelRatio;
static double _statusBarHeight;

static double _bottomBarHeight;

ScreenUtil({int width, int height}) {
designWidth = width;
designHeight = height;
_designWidth = width;
_designHeight = height;
}

static ScreenUtil getInstance() {
return instance;
}

//设备的像素密度
static double pixelRatio = window.devicePixelRatio;
void init(BuildContext context) {
MediaQueryData mediaQuery = MediaQuery.of(context);
_mediaQueryData = mediaQuery;
_pixelRatio = mediaQuery.devicePixelRatio;
_screenWidth = mediaQuery.size.width;
_screenHeight = mediaQuery.size.height;
_statusBarHeight = mediaQuery.padding.top;
_bottomBarHeight = _mediaQueryData.padding.bottom;
}

static MediaQueryData get mediaQueryData => _mediaQueryData;

///设备的像素密度
static double get pixelRatio => _pixelRatio;

//当前设备宽度 px
static double screenWidth = window.physicalSize.width;
///当前设备宽度 px
static double get screenWidth => _screenWidth * _pixelRatio;

//当前设备高度 px
static double screenHeight = window.physicalSize.height;
///当前设备高度 px
static double get screenHeight => _screenHeight * _pixelRatio;

//状态栏高度 刘海屏会更高
static double statusBarHeight = window.padding.top;
///状态栏高度 刘海屏会更高
static double get statusBarHeight => _statusBarHeight * _pixelRatio;

//底部安全区距离
static double bottomBarHeight = window.padding.bottom;
///底部安全区距离
static double get bottomBarHeight => _bottomBarHeight * _pixelRatio;

//相对于设计稿放大的倍数
double get scaleWidth => screenWidth / instance.designWidth / pixelRatio;
///相对于设计稿放大的倍数
get scaleWidth => _screenWidth / instance._designWidth;

double get scaleHeight => screenHeight / instance.designHeight / pixelRatio;
get scaleHeight => _screenHeight / instance._designHeight;

/**
* 根据设计稿的设备宽度适配
* 高度也根据这个来做适配可以保证不变形
*/
///根据设计稿的设备宽度适配
///高度也根据这个来做适配可以保证不变形
setWidth(int width) => width * scaleWidth;

/**
* 根据设计稿的设备高度适配
* 当发现设计稿中的一屏显示的与当前样式效果不符合时,
* 或者形状有差异时,高度适配建议使用此方法
* 高度适配主要针对想根据设计稿的一屏展示一样的效果
*/
/// 根据设计稿的设备高度适配
/// 当发现设计稿中的一屏显示的与当前样式效果不符合时,
/// 或者形状有差异时,高度适配建议使用此方法
/// 高度适配主要针对想根据设计稿的一屏展示一样的效果
setHeight(int height) => height * scaleHeight;
}
Loading

0 comments on commit eb6f740

Please sign in to comment.