mirror of
https://github.com/zjs81/meshcore-open.git
synced 2026-06-14 22:55:12 +10:00
chrome required screen
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
export 'browser_detection_stub.dart'
|
||||
if (dart.library.html) 'browser_detection_web.dart';
|
||||
@@ -0,0 +1,3 @@
|
||||
class BrowserDetection {
|
||||
static bool get isChrome => false;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
// ignore: avoid_web_libraries_in_flutter
|
||||
import 'dart:html' as html;
|
||||
|
||||
class BrowserDetection {
|
||||
static bool get isChrome {
|
||||
final userAgent = html.window.navigator.userAgent.toLowerCase();
|
||||
final vendor = html.window.navigator.vendor.toLowerCase();
|
||||
|
||||
// Chrome UA typically contains 'chrome' and vendor is 'Google Inc.'
|
||||
// This also excludes Firefox, Safari, and sometimes Edge/Brave depending on strictness.
|
||||
// For Web Bluetooth, Chrome, Edge (latest), and Brave usually work.
|
||||
// But we'll follow the user's request for "isChrome".
|
||||
return userAgent.contains('chrome') && vendor.contains('google');
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'dart:io' show Platform;
|
||||
import 'browser_detection.dart';
|
||||
|
||||
/// Utility class to safely check the current platform across web and native.
|
||||
///
|
||||
@@ -9,6 +10,9 @@ class PlatformInfo {
|
||||
/// Whether the app is running in a web browser.
|
||||
static bool get isWeb => kIsWeb;
|
||||
|
||||
/// Whether the app is running in the Chrome browser (only relevant if [isWeb] is true).
|
||||
static bool get isChrome => isWeb && BrowserDetection.isChrome;
|
||||
|
||||
/// Whether the app is running on Android.
|
||||
static bool get isAndroid => !kIsWeb && Platform.isAndroid;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user