diff --git a/packages/stream_chat/lib/src/platform_detector/platform_detector.dart b/packages/stream_chat/lib/src/platform_detector/platform_detector.dart index 8f601501..32748256 100644 --- a/packages/stream_chat/lib/src/platform_detector/platform_detector.dart +++ b/packages/stream_chat/lib/src/platform_detector/platform_detector.dart @@ -2,26 +2,56 @@ import 'platform_detector_stub.dart' if (dart.library.html) 'platform_detector_web.dart' if (dart.library.io) 'platform_detector_io.dart'; +/// Possible platforms enum PlatformType { + /// Android, + + /// Ios, + + /// Web, + + /// MacOS, + + /// Windows, + + /// Linux, + + /// Fuchsia, } +/// Utility class that provides information on the current platform class CurrentPlatform { CurrentPlatform._(); + + /// True if the app is running on android static bool get isAndroid => type == PlatformType.Android; + + /// True if the app is running on ios static bool get isIos => type == PlatformType.Ios; + + /// True if the app is running on web static bool get isWeb => type == PlatformType.Web; + + /// True if the app is running on macos static bool get isMacOS => type == PlatformType.MacOS; + + /// True if the app is running on windows static bool get isWindows => type == PlatformType.Windows; + + /// True if the app is running on linux static bool get isLinux => type == PlatformType.Linux; + + /// True if the app is running on fuchsia static bool get isFuchsia => type == PlatformType.Fuchsia; + /// Returns a string version of the platform static String get name { switch (type) { case PlatformType.Android: @@ -43,5 +73,6 @@ class CurrentPlatform { } } + /// Get current platform type static PlatformType get type => currentPlatform; } diff --git a/packages/stream_chat/lib/src/platform_detector/platform_detector_io.dart b/packages/stream_chat/lib/src/platform_detector/platform_detector_io.dart index 6cca45b6..df74f5d8 100644 --- a/packages/stream_chat/lib/src/platform_detector/platform_detector_io.dart +++ b/packages/stream_chat/lib/src/platform_detector/platform_detector_io.dart @@ -1,6 +1,7 @@ import 'dart:io'; import 'platform_detector.dart'; +/// Version running on native systems PlatformType get currentPlatform { if (Platform.isWindows) return PlatformType.Windows; if (Platform.isFuchsia) return PlatformType.Fuchsia; diff --git a/packages/stream_chat/lib/src/platform_detector/platform_detector_stub.dart b/packages/stream_chat/lib/src/platform_detector/platform_detector_stub.dart index 4469fc46..f9143deb 100644 --- a/packages/stream_chat/lib/src/platform_detector/platform_detector_stub.dart +++ b/packages/stream_chat/lib/src/platform_detector/platform_detector_stub.dart @@ -1,5 +1,6 @@ import 'platform_detector.dart'; +/// Stub implementation PlatformType get currentPlatform { throw UnimplementedError(); } diff --git a/packages/stream_chat/lib/src/platform_detector/platform_detector_web.dart b/packages/stream_chat/lib/src/platform_detector/platform_detector_web.dart index b1613afb..4274bf71 100644 --- a/packages/stream_chat/lib/src/platform_detector/platform_detector_web.dart +++ b/packages/stream_chat/lib/src/platform_detector/platform_detector_web.dart @@ -1,3 +1,4 @@ import 'platform_detector.dart'; +/// Version running on web PlatformType get currentPlatform => PlatformType.Web; diff --git a/packages/stream_chat_flutter/lib/src/channel_list_view.dart b/packages/stream_chat_flutter/lib/src/channel_list_view.dart index 9edd39ff..3bab76b2 100644 --- a/packages/stream_chat_flutter/lib/src/channel_list_view.dart +++ b/packages/stream_chat_flutter/lib/src/channel_list_view.dart @@ -1,6 +1,3 @@ -import 'dart:async'; -import 'dart:convert'; - import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_slidable/flutter_slidable.dart';