Skip to content

Commit

Permalink
将statusBarHeight和bottomBarHeight的单位更改为dp
Browse files Browse the repository at this point in the history
  • Loading branch information
lizhuoyuan committed Jun 22, 2019
1 parent 686d84e commit 261a80d
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 72 deletions.
42 changes: 21 additions & 21 deletions .packages
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
# Generated by pub on 2019-05-15 14:31:19.119581.
async:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/async-2.1.0/lib/
boolean_selector:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/boolean_selector-1.0.4/lib/
charcode:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/charcode-1.1.2/lib/
collection:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/collection-1.14.11/lib/
flutter:file:///D:/flutter/packages/flutter/lib/
flutter_test:file:///D:/flutter/packages/flutter_test/lib/
matcher:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/matcher-0.12.5/lib/
meta:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/meta-1.1.6/lib/
path:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/path-1.6.2/lib/
pedantic:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/pedantic-1.5.0/lib/
quiver:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/quiver-2.0.2/lib/
sky_engine:file:///D:/flutter/bin/cache/pkg/sky_engine/lib/
source_span:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/source_span-1.5.5/lib/
stack_trace:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/stack_trace-1.9.3/lib/
stream_channel:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/stream_channel-2.0.0/lib/
string_scanner:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/string_scanner-1.0.4/lib/
term_glyph:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/term_glyph-1.1.0/lib/
test_api:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/test_api-0.2.4/lib/
typed_data:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/typed_data-1.1.6/lib/
vector_math:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/vector_math-2.0.8/lib/
# Generated by pub on 2019-06-22 18:24:22.703599.
async:file:///D:/Develop/flutter/.pub-cache/hosted/pub.flutter-io.cn/async-2.1.0/lib/
boolean_selector:file:///D:/Develop/flutter/.pub-cache/hosted/pub.flutter-io.cn/boolean_selector-1.0.4/lib/
charcode:file:///D:/Develop/flutter/.pub-cache/hosted/pub.flutter-io.cn/charcode-1.1.2/lib/
collection:file:///D:/Develop/flutter/.pub-cache/hosted/pub.flutter-io.cn/collection-1.14.11/lib/
flutter:file:///D:/Develop/flutter/packages/flutter/lib/
flutter_test:file:///D:/Develop/flutter/packages/flutter_test/lib/
matcher:file:///D:/Develop/flutter/.pub-cache/hosted/pub.flutter-io.cn/matcher-0.12.5/lib/
meta:file:///D:/Develop/flutter/.pub-cache/hosted/pub.flutter-io.cn/meta-1.1.6/lib/
path:file:///D:/Develop/flutter/.pub-cache/hosted/pub.flutter-io.cn/path-1.6.2/lib/
pedantic:file:///D:/Develop/flutter/.pub-cache/hosted/pub.flutter-io.cn/pedantic-1.5.0/lib/
quiver:file:///D:/Develop/flutter/.pub-cache/hosted/pub.flutter-io.cn/quiver-2.0.2/lib/
sky_engine:file:///D:/Develop/flutter/bin/cache/pkg/sky_engine/lib/
source_span:file:///D:/Develop/flutter/.pub-cache/hosted/pub.flutter-io.cn/source_span-1.5.5/lib/
stack_trace:file:///D:/Develop/flutter/.pub-cache/hosted/pub.flutter-io.cn/stack_trace-1.9.3/lib/
stream_channel:file:///D:/Develop/flutter/.pub-cache/hosted/pub.flutter-io.cn/stream_channel-2.0.0/lib/
string_scanner:file:///D:/Develop/flutter/.pub-cache/hosted/pub.flutter-io.cn/string_scanner-1.0.4/lib/
term_glyph:file:///D:/Develop/flutter/.pub-cache/hosted/pub.flutter-io.cn/term_glyph-1.1.0/lib/
test_api:file:///D:/Develop/flutter/.pub-cache/hosted/pub.flutter-io.cn/test_api-0.2.4/lib/
typed_data:file:///D:/Develop/flutter/.pub-cache/hosted/pub.flutter-io.cn/typed_data-1.1.6/lib/
vector_math:file:///D:/Develop/flutter/.pub-cache/hosted/pub.flutter-io.cn/vector_math-2.0.8/lib/
flutter_screenutil:lib/
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## [0.0.1] - first version
## [0.0.1] - first version

## [0.2.2] - Fixed bug when releasing

Expand Down Expand Up @@ -40,4 +40,6 @@ It is recommended to use `ScreenUtil.getInstance()` instead of `ScreenUtil()` ,

setWidth,setHeight,setSp.
for example:
you can use setWidth(100) or setWidth(100.0)
you can use setWidth(100) or setWidth(100.0)

## [0.5.3] - Change the units of statusBarHeight and bottomBarHeight to dp
8 changes: 4 additions & 4 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ class _MyHomePageState extends State<MyHomePage> {
print(
'Device pixel density:${ScreenUtil.pixelRatio}'); //Device pixel density
print(
'Bottom safe zone distance px:${ScreenUtil.bottomBarHeight}'); //Bottom safe zone distance,suitable for buttons with full screen
'Bottom safe zone distance dp:${ScreenUtil.bottomBarHeight}'); //Bottom safe zone distance,suitable for buttons with full screen
print(
'Status bar height px:${ScreenUtil.statusBarHeight}px'); //Status bar height , Notch will be higher Unit px
'Status bar height px:${ScreenUtil.statusBarHeight}dp'); //Status bar height , Notch will be higher Unit px
print(
'Ratio of actual width dp to design draft px:${ScreenUtil.getInstance().scaleWidth}');
print(
Expand Down Expand Up @@ -88,8 +88,8 @@ class _MyHomePageState extends State<MyHomePage> {
Text('Device width:${ScreenUtil.screenWidthDp}dp'),
Text('Device height:${ScreenUtil.screenHeightDp}dp'),
Text('Device pixel density:${ScreenUtil.pixelRatio}'),
Text('Bottom safe zone distance:${ScreenUtil.bottomBarHeight}px'),
Text('Status bar height:${ScreenUtil.statusBarHeight}px'),
Text('Bottom safe zone distance:${ScreenUtil.bottomBarHeight}dp'),
Text('Status bar height:${ScreenUtil.statusBarHeight}dp'),
Text(
'Ratio of actual width dp to design draft px:${ScreenUtil.getInstance().scaleWidth}',
textAlign: TextAlign.center,
Expand Down
8 changes: 4 additions & 4 deletions example/lib/main_zh.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ class _MyHomePageState extends State<MyHomePage> {
print('设备高度:${ScreenUtil.screenHeight}'); //Device height
print('设备的像素密度:${ScreenUtil.pixelRatio}'); //Device pixel density
print(
'底部安全区距离:${ScreenUtil.bottomBarHeight}'); //Bottom safe zone distance,suitable for buttons with full screen
'底部安全区距离:${ScreenUtil.bottomBarHeight}dp'); //Bottom safe zone distance,suitable for buttons with full screen
print(
'状态栏高度:${ScreenUtil.statusBarHeight}px'); //Status bar height , Notch will be higher Unit px
'状态栏高度:${ScreenUtil.statusBarHeight}dp'); //Status bar height , Notch will be higher Unit px

print('实际宽度的dp与设计稿px的比例:${ScreenUtil.getInstance().scaleWidth}');
print('实际高度的dp与设计稿px的比例:${ScreenUtil.getInstance().scaleHeight}');
Expand Down Expand Up @@ -98,8 +98,8 @@ class _MyHomePageState extends State<MyHomePage> {
Text('设备高度:${ScreenUtil.screenHeightDp}dp'),
Text('设计稿宽度:${ScreenUtil.getInstance().width}'),
Text('设备的像素密度:${ScreenUtil.pixelRatio}'),
Text('底部安全区距离:${ScreenUtil.bottomBarHeight}px'),
Text('状态栏高度:${ScreenUtil.statusBarHeight}px'),
Text('底部安全区距离:${ScreenUtil.bottomBarHeight}dp'),
Text('状态栏高度:${ScreenUtil.statusBarHeight}dp'),
Text(
'实际宽度的dp与设计稿px的比例:${ScreenUtil.getInstance().scaleWidth}',
textAlign: TextAlign.center,
Expand Down
38 changes: 19 additions & 19 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,35 @@ packages:
dependency: transitive
description:
name: async
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.1.0"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.0.4"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.1.2"
collection:
dependency: transitive
description:
name: collection
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.14.11"
cupertino_icons:
dependency: "direct main"
description:
name: cupertino_icons
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.1.2"
flutter:
Expand All @@ -47,7 +47,7 @@ packages:
path: ".."
relative: true
source: path
version: "0.5.2"
version: "0.5.3"
flutter_test:
dependency: "direct dev"
description: flutter
Expand All @@ -57,35 +57,35 @@ packages:
dependency: transitive
description:
name: matcher
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.12.5"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.1.6"
path:
dependency: transitive
description:
name: path
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.6.2"
pedantic:
dependency: transitive
description:
name: pedantic
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.5.0"
quiver:
dependency: transitive
description:
name: quiver
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.0.2"
sky_engine:
Expand All @@ -97,56 +97,56 @@ packages:
dependency: transitive
description:
name: source_span
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.5.5"
stack_trace:
dependency: transitive
description:
name: stack_trace
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.9.3"
stream_channel:
dependency: transitive
description:
name: stream_channel
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.0.0"
string_scanner:
dependency: transitive
description:
name: string_scanner
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.0.4"
term_glyph:
dependency: transitive
description:
name: term_glyph
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.1.0"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.2.4"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.1.6"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.0.8"
sdks:
Expand Down
8 changes: 4 additions & 4 deletions lib/flutter_screenutil.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ class ScreenUtil {
///当前设备高度 px
static double get screenHeight => _screenHeight * _pixelRatio;

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

///底部安全区距离
static double get bottomBarHeight => _bottomBarHeight * _pixelRatio;
///底部安全区距离 dp
static double get bottomBarHeight => _bottomBarHeight;

///实际的dp与设计稿px的比例
get scaleWidth => _screenWidth / instance.width;
Expand Down
Loading

0 comments on commit 261a80d

Please sign in to comment.