add platform type to userAgent header
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
import 'platform_detector_web.dart' if (dart.library.io) 'src/platform_io.dart';
|
||||
|
||||
enum PlatformType {
|
||||
Android,
|
||||
Ios,
|
||||
Web,
|
||||
MacOS,
|
||||
Windows,
|
||||
Linux,
|
||||
Fuchsia,
|
||||
}
|
||||
|
||||
abstract class Platform {
|
||||
static bool get isAndroid => currentPlatform == PlatformType.Android;
|
||||
static bool get isIos => currentPlatform == PlatformType.Ios;
|
||||
static bool get isWeb => currentPlatform == PlatformType.Web;
|
||||
static bool get isMacOS => currentPlatform == PlatformType.MacOS;
|
||||
static bool get isWindows => currentPlatform == PlatformType.Windows;
|
||||
static bool get isLinux => currentPlatform == PlatformType.Linux;
|
||||
static bool get isFuchsia => currentPlatform == PlatformType.Fuchsia;
|
||||
|
||||
static String get name {
|
||||
switch (currentPlatform) {
|
||||
case PlatformType.Android:
|
||||
return 'android';
|
||||
case PlatformType.Ios:
|
||||
return 'ios';
|
||||
case PlatformType.Web:
|
||||
return 'web';
|
||||
case PlatformType.MacOS:
|
||||
return 'macos';
|
||||
case PlatformType.Windows:
|
||||
return 'windows';
|
||||
case PlatformType.Linux:
|
||||
return 'linux';
|
||||
case PlatformType.Fuchsia:
|
||||
return 'fuchsia';
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
PlatformType get type => currentPlatform;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import 'dart:io';
|
||||
import 'platform_detector.dart';
|
||||
|
||||
PlatformType get currentPlatform {
|
||||
if (Platform.isWindows) return PlatformType.Windows;
|
||||
if (Platform.isFuchsia) return PlatformType.Fuchsia;
|
||||
if (Platform.isMacOS) return PlatformType.MacOS;
|
||||
if (Platform.isLinux) return PlatformType.Linux;
|
||||
if (Platform.isIos) return PlatformType.Ios;
|
||||
return PlatformType.Android;
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
import 'platform_detector.dart';
|
||||
|
||||
PlatformType get currentPlatform => PlatformType.Web;
|
||||
Reference in New Issue
Block a user