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
李卓原
2022-02-14 11:30:26 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
a7fd8ec53b21b1445cecedf23dd85220b8f20665
a7fd8ec5
1 parent
4eef4471
fix #327 #340
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
5 deletions
example/lib/main.dart
lib/screen_util.dart
example/lib/main.dart
View file @
a7fd8ec
...
...
@@ -29,7 +29,7 @@ class MyApp extends StatelessWidget {
child:
widget
,
);
},
home:
HomePage
(
title:
'FlutterScreenUtil Demo'
),
home:
const
HomePage
(
title:
'FlutterScreenUtil Demo'
),
),
);
}
...
...
lib/screen_util.dart
View file @
a7fd8ec
...
...
@@ -63,19 +63,23 @@ class ScreenUtil {
/// 当前设备宽度 dp
/// The horizontal extent of this size.
double
get
screenWidth
=>
_screenWidth
;
double
get
screenWidth
=>
context
!=
null
?
MediaQuery
.
of
(
context
!).
size
.
width
:
_screenWidth
;
///当前设备高度 dp
///The vertical extent of this size. dp
double
get
screenHeight
=>
_screenHeight
;
double
get
screenHeight
=>
context
!=
null
?
MediaQuery
.
of
(
context
!).
size
.
height
:
_screenHeight
;
/// 状态栏高度 dp 刘海屏会更高
/// The offset from the top, in dp
double
get
statusBarHeight
=>
MediaQuery
.
of
(
context
!).
padding
.
top
;
double
get
statusBarHeight
=>
context
==
null
?
0
:
MediaQuery
.
of
(
context
!).
padding
.
top
;
/// 底部安全区距离 dp
/// The offset from the bottom, in dp
double
get
bottomBarHeight
=>
MediaQuery
.
of
(
context
!).
padding
.
bottom
;
double
get
bottomBarHeight
=>
context
==
null
?
0
:
MediaQuery
.
of
(
context
!).
padding
.
bottom
;
/// 实际尺寸与UI设计的比例
/// The ratio of actual width to UI design
...
...
Please
register
or
login
to post a comment