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
Sushil Ghorasaini
2021-02-10 23:00:42 +0545
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
dab45b8730741a5bfa3a66e4245a7f00531e423e
dab45b87
1 parent
e53982f1
Fixing size changes on device orientation change
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
2 deletions
lib/screenutil.dart
lib/screenutil_init.dart
lib/screenutil.dart
View file @
dab45b8
...
...
@@ -35,7 +35,9 @@ class ScreenUtil {
}
static
void
init
(
BoxConstraints
constraints
,
{
BoxConstraints
constraints
,
Orientation
orientation
,
{
Size
designSize
=
defaultSize
,
bool
allowFontScaling
=
false
,
})
{
...
...
@@ -43,8 +45,13 @@ class ScreenUtil {
_instance
..
uiSize
=
designSize
..
allowFontScaling
=
allowFontScaling
;
if
(
orientation
==
Orientation
.
potrait
){
_screenWidth
=
constraints
.
maxWidth
;
_screenHeight
=
constraints
.
maxHeight
;
}
else
{
_screenWidth
=
constraints
.
maxHeight
;
_screenHeight
=
constraints
.
maxWidth
;
}
var
window
=
WidgetsBinding
.
instance
?.
window
??
ui
.
window
;
_pixelRatio
=
window
.
devicePixelRatio
;
...
...
lib/screenutil_init.dart
View file @
dab45b8
...
...
@@ -22,11 +22,14 @@ class ScreenUtilInit extends StatelessWidget {
@override
Widget
build
(
BuildContext
context
)
{
return
LayoutBuilder
(
// ignore: missing_return
builder:
(
_
,
BoxConstraints
constraints
)
{
return
OrientationBuilder
(
builder:
(
_
,
Orientation
orientation
)
{
// ignore: missing_return
if
(
constraints
.
maxWidth
!=
0
)
{
ScreenUtil
.
init
(
constraints
,
orientation
,
designSize:
designSize
,
allowFontScaling:
allowFontScaling
,
);
...
...
@@ -34,5 +37,7 @@ class ScreenUtilInit extends StatelessWidget {
return
builder
();
},
);
},
);
}
}
...
...
Please
register
or
login
to post a comment