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-10 14:53:58 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
0be3b2eec6cae5ec4d59db0c0edb356e02d3cc8b
0be3b2ee
1 parent
6d42e28b
使用MediaQuery包裹LayoutBuilder
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
16 deletions
lib/screenutil_init.dart
lib/screenutil_init.dart
View file @
0be3b2e
...
...
@@ -19,21 +19,24 @@ class ScreenUtilInit extends StatelessWidget {
@override
Widget
build
(
BuildContext
context
)
{
return
LayoutBuilder
(
builder:
(
_
,
BoxConstraints
constraints
)
{
if
(
constraints
.
maxWidth
!=
0
)
{
final
Orientation
orientation
=
constraints
.
maxWidth
>
constraints
.
maxHeight
?
Orientation
.
landscape
:
Orientation
.
portrait
;
ScreenUtil
.
init
(
constraints
,
context:
_
,
orientation:
orientation
,
designSize:
designSize
,
splitScreenMode:
splitScreenMode
,
minTextAdapt:
minTextAdapt
);
return
builder
();
}
return
Container
();
});
return
MediaQuery
(
data:
MediaQueryData
.
fromWindow
(
WidgetsBinding
.
instance
!.
window
),
child:
LayoutBuilder
(
builder:
(
_
,
BoxConstraints
constraints
)
{
if
(
constraints
.
maxWidth
!=
0
)
{
final
Orientation
orientation
=
constraints
.
maxWidth
>
constraints
.
maxHeight
?
Orientation
.
landscape
:
Orientation
.
portrait
;
ScreenUtil
.
init
(
constraints
,
context:
_
,
orientation:
orientation
,
designSize:
designSize
,
splitScreenMode:
splitScreenMode
,
minTextAdapt:
minTextAdapt
);
return
builder
();
}
return
Container
();
}),
);
}
}
...
...
Please
register
or
login
to post a comment