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
zhuoyuan
2022-04-29 13:07:47 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
dc21e4a773faadb109f7b4c4ea16f23f70ad23b4
dc21e4a7
1 parent
2ddac242
修正宽度和高度为无视屏幕的方向
example添加textfield方便测试
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
4 deletions
example/lib/src/home.dart
lib/src/screen_util.dart
example/lib/src/home.dart
View file @
dc21e4a
...
...
@@ -31,6 +31,7 @@ class HomePageScaffold extends StatelessWidget {
child:
Column
(
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
<
Widget
>[
TextField
(),
Row
(
children:
<
Widget
>[
// Using Extensions
...
...
lib/src/screen_util.dart
View file @
dc21e4a
...
...
@@ -121,13 +121,43 @@ class ScreenUtil {
/// 当前设备宽度 dp
/// The horizontal extent of this size.
double
get
screenWidth
=>
context
!=
null
?
MediaQuery
.
of
(
context
!).
size
.
width
:
_screenWidth
;
double
get
screenWidth
{
if
(
_orientation
==
Orientation
.
landscape
)
{
return
(
context
!=
null
?
MediaQuery
.
of
(
context
!).
size
.
height
:
_screenHeight
);
}
return
context
!=
null
?
MediaQuery
.
of
(
context
!).
size
.
width
:
_screenWidth
;
}
///当前设备高度 dp
///The vertical extent of this size. dp
double
get
screenHeight
=>
context
!=
null
?
MediaQuery
.
of
(
context
!).
size
.
height
:
_screenHeight
;
double
get
screenHeight
{
if
(
_orientation
==
Orientation
.
landscape
)
{
return
context
!=
null
?
MediaQuery
.
of
(
context
!).
size
.
width
:
_screenWidth
;
}
return
context
!=
null
?
MediaQuery
.
of
(
context
!).
size
.
height
:
_screenHeight
;
}
Size
get
screenSize
{
if
(
_orientation
==
Orientation
.
landscape
)
{
double
width
=
(
context
!=
null
?
MediaQuery
.
of
(
context
!).
size
.
height
:
_screenHeight
)
+
bottomBarHeight
;
double
height
=
(
context
!=
null
?
MediaQuery
.
of
(
context
!).
size
.
width
:
_screenWidth
);
return
Size
(
width
,
height
);
}
return
Size
(
context
!=
null
?
MediaQuery
.
of
(
context
!).
size
.
width
:
_screenWidth
,
context
!=
null
?
MediaQuery
.
of
(
context
!).
size
.
height
:
_screenHeight
);
}
/// 状态栏高度 dp 刘海屏会更高
/// The offset from the top, in dp
...
...
Please
register
or
login
to post a comment