better platform check
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
import 'platform/io.dart' if (dart.library.html) 'platform/web.dart';
|
||||
|
||||
// Returns the current platform which works for both web and devices.
|
||||
PlatformType lkPlatform() => lkPlatformImplementation();
|
||||
bool lkPlatformIs(PlatformType type) => lkPlatform() == type;
|
||||
|
||||
enum PlatformType {
|
||||
web,
|
||||
windows,
|
||||
linux,
|
||||
macOS,
|
||||
android,
|
||||
fuchsia,
|
||||
iOS,
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import '../platform.dart';
|
||||
import 'dart:io';
|
||||
|
||||
PlatformType lkPlatformImplementation() {
|
||||
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.dart';
|
||||
|
||||
PlatformType lkPlatformImplementation() => PlatformType.web;
|
||||
@@ -1,4 +1,4 @@
|
||||
import 'platforms/io.dart' if (dart.library.html) 'platforms/web.dart';
|
||||
import 'websocket/io.dart' if (dart.library.html) 'websocket/web.dart';
|
||||
|
||||
class WebSocketException implements Exception {
|
||||
final int code;
|
||||
|
||||
Reference in New Issue
Block a user