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
Mounir Bouaiche
2024-05-30 18:00:28 +0100
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
f9651f83d1adb92f7d08ba56b68653955c54594e
f9651f83
1 parent
9f63be0c
Depend on View instead of MediaQuery
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
9 deletions
lib/src/screen_util.dart
lib/src/screenutil_init.dart
lib/src/screen_util.dart
View file @
f9651f8
...
...
@@ -141,8 +141,9 @@ class ScreenUtil {
bool
minTextAdapt
=
false
,
FontSizeResolver
?
fontSizeResolver
,
})
{
final
view
=
View
.
maybeOf
(
context
);
return
configure
(
data:
MediaQuery
.
maybeOf
(
context
)
,
data:
view
!=
null
?
MediaQueryData
.
fromView
(
view
)
:
null
,
designSize:
designSize
,
splitScreenMode:
splitScreenMode
,
minTextAdapt:
minTextAdapt
,
...
...
@@ -158,8 +159,8 @@ class ScreenUtil {
FontSizeResolver
?
fontSizeResolver
,
})
{
return
ScreenUtil
.
ensureScreenSize
().
then
((
_
)
{
return
configure
(
data:
MediaQuery
.
maybeOf
(
context
),
return
init
(
context
,
designSize:
designSize
,
minTextAdapt:
minTextAdapt
,
splitScreenMode:
splitScreenMode
,
...
...
@@ -251,8 +252,11 @@ class ScreenUtil {
if
(
kIsWeb
)
{
deviceType
=
DeviceType
.
web
;
}
else
{
bool
isMobile
=
defaultTargetPlatform
==
TargetPlatform
.
iOS
||
defaultTargetPlatform
==
TargetPlatform
.
android
;
bool
isTablet
=
(
orientation
==
Orientation
.
portrait
&&
screenWidth
>=
600
)
||
(
orientation
==
Orientation
.
landscape
&&
screenHeight
>=
600
);
bool
isMobile
=
defaultTargetPlatform
==
TargetPlatform
.
iOS
||
defaultTargetPlatform
==
TargetPlatform
.
android
;
bool
isTablet
=
(
orientation
==
Orientation
.
portrait
&&
screenWidth
>=
600
)
||
(
orientation
==
Orientation
.
landscape
&&
screenHeight
>=
600
);
if
(
isMobile
)
{
deviceType
=
isTablet
?
DeviceType
.
tablet
:
DeviceType
.
mobile
;
...
...
lib/src/screenutil_init.dart
View file @
f9651f8
...
...
@@ -126,10 +126,9 @@ class _ScreenUtilInitState extends State<ScreenUtilInit>
}
MediaQueryData
?
_newData
()
{
MediaQueryData
?
mq
=
MediaQuery
.
maybeOf
(
context
);
if
(
mq
==
null
)
mq
=
MediaQueryData
.
fromView
(
View
.
of
(
context
));
return
mq
;
final
view
=
View
.
maybeOf
(
context
);
if
(
view
!=
null
)
return
MediaQueryData
.
fromView
(
view
);
return
null
;
}
Future
<
void
>
_validateSize
()
async
{
...
...
Please
register
or
login
to post a comment