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
李卓原
2020-12-09 19:26:28 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
bb98d5d516e65264a64bb9f29830808950c0b892
bb98d5d5
1 parent
0c8b90a3
update example,code annotation
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
13 deletions
example/lib/main.dart
example/lib/main_zh.dart
lib/screenutil.dart
example/lib/main.dart
View file @
bb98d5d
...
...
@@ -127,17 +127,17 @@ class _HomePageState extends State<HomePage> {
}
void
printScreenInformation
()
{
print
(
'Device width dp:
${1.sw}
'
);
//Device width
print
(
'Device height dp:
${1.sh}
'
);
//Device height
print
(
'Device pixel density:
${ScreenUtil().pixelRatio}
'
);
//Device pixel density
print
(
'Device width dp:
${1.sw}
dp'
);
print
(
'Device height dp:
${1.sh}
dp'
);
print
(
'Device pixel density:
${ScreenUtil().pixelRatio}
'
);
print
(
'Bottom safe zone distance dp:
${ScreenUtil().bottomBarHeight}
'
);
//Bottom safe zone distance,suitable for buttons with full screen
'Bottom safe zone distance dp:
${ScreenUtil().bottomBarHeight}
dp'
);
print
(
'Status bar height
px:
${ScreenUtil().statusBarHeight}
dp'
);
//Status bar height , Notch will be higher Unit px
'Status bar height
dp:
${ScreenUtil().statusBarHeight}
dp'
);
print
(
'Ratio of actual width dp to UI Design:
${ScreenUtil().scaleWidth}
'
);
print
(
'Ratio of actual height dp to UI Design:
${ScreenUtil().scaleHeight}
'
);
print
(
'System font scaling:
${ScreenUtil().textScaleFactor}
'
);
print
(
'0.5 times the screen width:
${0.5.sw}
'
);
print
(
'0.5 times the screen height:
${0.5.sh}
'
);
print
(
'0.5 times the screen width:
${0.5.sw}
dp'
);
print
(
'0.5 times the screen height:
${0.5.sh}
dp'
);
}
}
...
...
example/lib/main_zh.dart
View file @
bb98d5d
...
...
@@ -116,8 +116,8 @@ class _HomePageState extends State<HomePage> {
}
void
printScreenInformation
()
{
print
(
'设备宽度:
${1.sw}
'
);
print
(
'设备高度:
${1.sh}
'
);
print
(
'设备宽度:
${1.sw}
dp'
);
print
(
'设备高度:
${1.sh}
dp'
);
print
(
'设备的像素密度:
${ScreenUtil().pixelRatio}
'
);
print
(
'底部安全区距离:
${ScreenUtil().bottomBarHeight}
dp'
);
print
(
'状态栏高度:
${ScreenUtil().statusBarHeight}
dp'
);
...
...
@@ -126,7 +126,7 @@ class _HomePageState extends State<HomePage> {
print
(
'宽度和字体相对于设计稿放大的比例:
${ScreenUtil().scaleWidth * ScreenUtil().pixelRatio}
'
);
print
(
'高度相对于设计稿放大的比例:
${ScreenUtil().scaleHeight * ScreenUtil().pixelRatio}
'
);
print
(
'系统的字体缩放比例:
${ScreenUtil().textScaleFactor}
'
);
print
(
'屏幕宽度的0.5:
${0.5.sw}
'
);
print
(
'屏幕高度的0.5:
${0.5.sh}
'
);
print
(
'屏幕宽度的0.5:
${0.5.sw}
dp'
);
print
(
'屏幕高度的0.5:
${0.5.sh}
dp'
);
}
}
...
...
lib/screenutil.dart
View file @
bb98d5d
...
...
@@ -79,11 +79,11 @@ class ScreenUtil {
double
get
screenHeightPx
=>
_screenHeight
*
_pixelRatio
;
/// 状态栏高度 dp 刘海屏会更高
/// The offset from the top
/// The offset from the top
, in dp
double
get
statusBarHeight
=>
_statusBarHeight
/
_pixelRatio
;
/// 底部安全区距离 dp
/// The offset from the bottom
.
/// The offset from the bottom
, in dp
double
get
bottomBarHeight
=>
_bottomBarHeight
/
_pixelRatio
;
/// 实际的dp与UI设计px的比例
...
...
Please
register
or
login
to post a comment