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
Jonny Borges
2020-08-31 23:45:34 -0300
Browse Files
Options
Browse Files
Download
Plain Diff
Committed by
GitHub
2020-08-31 23:45:34 -0300
Commit
a086da17e9f9ef6f619c5c1c984cb5994d75f5e9
a086da17
2 parents
85979f2a
e2e271f8
Merge pull request #539 from roipeker/master
Fixes and features
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
51 additions
and
8 deletions
lib/src/utils/extensions/context_extensions.dart
lib/src/utils/extensions/dynamic_extensions.dart
lib/src/utils/platform/platform.dart
lib/src/utils/platform/platform_io.dart
lib/src/utils/platform/platform_web.dart
lib/src/utils/regex/get_utils.dart
lib/src/utils/extensions/context_extensions.dart
View file @
a086da1
import
'package:flutter/material.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:
flutter/foundation
.dart'
;
import
'package:
get/get
.dart'
;
extension
ContextExtensionss
on
BuildContext
{
/// The same of [MediaQuery.of(context).size]
...
...
@@ -117,8 +117,7 @@ extension ContextExtensionss on BuildContext {
T
watch
,
})
{
double
deviceWidth
=
mediaQuerySize
.
shortestSide
;
if
(
kIsWeb
)
{
if
(
GetPlatform
.
isDesktop
)
{
deviceWidth
=
mediaQuerySize
.
width
;
}
if
(
deviceWidth
>=
1200
&&
desktop
!=
null
)
return
desktop
;
...
...
lib/src/utils/extensions/dynamic_extensions.dart
View file @
a086da1
...
...
@@ -3,6 +3,12 @@ import '../regex/get_utils.dart';
extension
GetDynamicUtils
on
dynamic
{
/// It's This is overloading the IDE's options. Only the most useful and popular options will stay here.
/// In dart2js (in flutter v1.17) a var by default is undefined.
/// *Use this only if you are in version <- 1.17*.
/// So we assure the null type in json convertions to avoid the "value":value==null?null:value;
/// someVar.nil will force the null type if the var is null or undefined.
/// `nil` taken from ObjC just to have a shorter sintax.
dynamic
get
nil
=>
GetUtils
.
nil
(
this
);
bool
get
isNull
=>
GetUtils
.
isNull
(
this
);
bool
get
isNullOrBlank
=>
GetUtils
.
isNullOrBlank
(
this
);
...
...
lib/src/utils/platform/platform.dart
View file @
a086da1
...
...
@@ -8,4 +8,7 @@ class GetPlatform {
static
bool
get
isAndroid
=>
GeneralPlatform
.
isAndroid
;
static
bool
get
isIOS
=>
GeneralPlatform
.
isIOS
;
static
bool
get
isFuchsia
=>
GeneralPlatform
.
isFuchsia
;
static
bool
get
isMobile
=>
GetPlatform
.
isIOS
||
GetPlatform
.
isAndroid
;
static
bool
get
isDesktop
=>
GetPlatform
.
isMacOS
||
GetPlatform
.
isWindows
||
GetPlatform
.
isLinux
;
}
...
...
lib/src/utils/platform/platform_io.dart
View file @
a086da1
...
...
@@ -8,4 +8,6 @@ class GeneralPlatform {
static
bool
get
isAndroid
=>
Platform
.
isAndroid
;
static
bool
get
isIOS
=>
Platform
.
isIOS
;
static
bool
get
isFuchsia
=>
Platform
.
isFuchsia
;
static
bool
get
isDesktop
=>
Platform
.
isMacOS
||
Platform
.
isWindows
||
Platform
.
isLinux
;
}
...
...
lib/src/utils/platform/platform_web.dart
View file @
a086da1
// TODO: resolve platform/desktop by JS browser agent.
// ignore: avoid_web_libraries_in_flutter
import
'dart:html'
as
html
;
import
'package:get/utils.dart'
;
html
.
Navigator
_navigator
=
html
.
window
.
navigator
;
class
GeneralPlatform
{
static
bool
get
isWeb
=>
true
;
static
bool
get
isMacOS
=>
false
;
static
bool
get
isWindows
=>
false
;
static
bool
get
isLinux
=>
false
;
static
bool
get
isAndroid
=>
false
;
static
bool
get
isIOS
=>
false
;
static
bool
get
isMacOS
=>
_navigator
.
appVersion
.
contains
(
'Mac OS'
)
&&
!
GeneralPlatform
.
isIOS
;
static
bool
get
isWindows
=>
_navigator
.
appVersion
.
contains
(
'Win'
);
static
bool
get
isLinux
=>
(
_navigator
.
appVersion
.
contains
(
'Linux'
)
||
_navigator
.
appVersion
.
contains
(
'x11'
))
&&
!
isAndroid
;
// @check https://developer.chrome.com/multidevice/user-agent
static
bool
get
isAndroid
=>
_navigator
.
appVersion
.
contains
(
'Android '
);
static
bool
get
isIOS
{
// maxTouchPoints is needed to separate iPad iOS13 vs new MacOS
return
GetUtils
.
hasMatch
(
_navigator
.
platform
,
r'/iPad|iPhone|iPod/'
)
||
(
_navigator
.
platform
==
'MacIntel'
&&
_navigator
.
maxTouchPoints
>
1
);
}
static
bool
get
isFuchsia
=>
false
;
static
bool
get
isDesktop
=>
isMacOS
||
isWindows
||
isLinux
;
}
...
...
lib/src/utils/regex/get_utils.dart
View file @
a086da1
...
...
@@ -2,6 +2,13 @@ class GetUtils {
/// Checks if data is null.
static
bool
isNull
(
dynamic
s
)
=>
s
==
null
;
/// In dart2js (in flutter v1.17) a var by default is undefined.
/// *Use this only if you are in version <- 1.17*.
/// So we assure the null type in json convertions to avoid the "value":value==null?null:value;
/// someVar.nil will force the null type if the var is null or undefined.
/// `nil` taken from ObjC just to have a shorter sintax.
static
dynamic
nil
(
dynamic
s
)
=>
s
==
null
?
null
:
s
;
/// Checks if data is null or blank (empty or only contains whitespace).
static
bool
isNullOrBlank
(
dynamic
s
)
{
if
(
isNull
(
s
))
return
true
;
...
...
@@ -475,4 +482,6 @@ class GetUtils {
static
bool
hasMatch
(
String
s
,
Pattern
p
)
=>
(
s
==
null
)
?
false
:
RegExp
(
p
).
hasMatch
(
s
);
}
...
...
Please
register
or
login
to post a comment