Toggle navigation
Toggle navigation
This project
Loading...
Sign in
flutter_package
/
fluttertpc_get
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
Ahmed Fwela
2021-10-05 02:57:10 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
eb4357e2573ca44ad4ea7dd944b978c8062c0d86
eb4357e2
1 parent
50799df2
fix responsiveValue 2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
18 deletions
lib/get_utils/src/extensions/context_extensions.dart
lib/get_utils/src/extensions/context_extensions.dart
View file @
eb4357e
import
'package:flutter/material.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:collection/collection.dart'
;
import
'../platform/platform.dart'
;
extension
ContextExtensionss
on
BuildContext
{
...
...
@@ -120,30 +120,22 @@ extension ContextExtensionss on BuildContext {
/// if the device width is less than 300 return [watch] value.
/// in other cases return [mobile] value.
T
responsiveValue
<
T
>({
T
?
watch
,
T
?
mobile
,
T
?
tablet
,
T
?
desktop
,
T
?
watch
,
})
{
var
deviceWidth
=
mediaQuerySize
.
shortestSide
;
if
(
GetPlatform
.
isDesktop
)
{
deviceWidth
=
mediaQuerySize
.
width
;
}
if
(
deviceWidth
>=
1200
)
{
if
(
desktop
!=
null
)
{
return
desktop
;
}
}
if
(
deviceWidth
>=
600
)
{
if
(
tablet
!=
null
)
{
return
tablet
;
}
}
if
(
deviceWidth
>=
300
)
{
if
(
mobile
!=
null
)
{
return
mobile
;
}
}
return
watch
!;
//big screen width can display smaller sizes
final
values
=
[
if
(
deviceWidth
>=
1200
)
desktop
,
//desktop is allowed
if
(
deviceWidth
>=
600
)
tablet
,
//tablet is allowed
if
(
deviceWidth
>=
300
)
mobile
,
//mobile is allowed
watch
,
//watch is allowed
];
return
values
.
whereType
<
T
>().
first
;
}
}
...
...
Please
register
or
login
to post a comment