Jonny Borges
Committed by GitHub

Merge pull request #539 from roipeker/master

Fixes and features
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;
... ...
... ... @@ -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);
... ...
... ... @@ -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;
}
... ...
... ... @@ -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;
}
... ...
// 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;
}
... ...
... ... @@ -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);
}
... ...