Skip to content

Commit

Permalink
Release 3.1.0 version
Browse files Browse the repository at this point in the history
  • Loading branch information
vicajilau committed Aug 6, 2023
1 parent 4561868 commit 145aba9
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 13 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 3.1.0

* Renamed type by currentGroupPlatform
* Added currentPlatform to get an enumeration indicating the current operating system on which it is running.
* Upgraded documentation.
* Updated dependencies.

## 3.0.1

* Renamed PlatformDetails by PlatformDetail
Expand Down
41 changes: 29 additions & 12 deletions lib/src/platform_detail.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,26 @@ enum PlatformGroup { mobile, desktop, web }
/// Groups in an enumerated list the type of theme the device is configured with.
enum DeviceTheme { light, dark }

/// Allows you to determine platform details such as operating system or environment
/// Allows you to determine platform details such as operating system or environment.
class PlatformDetail {
/// This parameter returns an enum with the group of platform related
/// This parameter returns an enum with the group of platform related.
static PlatformGroup get currentGroupPlatform {
if (isWeb) {
return PlatformGroup.web;
} else if (isDesktop) {
return PlatformGroup.desktop;
} else if (isMobile) {
return PlatformGroup.mobile;
}
throw Exception('Platform ($defaultTargetPlatform) unrecognized.');
}

/// This parameter returns the current platform.
static TargetPlatform get currentPlatform {
return defaultTargetPlatform;
}

/// This parameter returns an enum with the group of platform related.
static PlatformGroup get type {
if (isWeb) {
return PlatformGroup.web;
Expand All @@ -36,42 +53,42 @@ class PlatformDetail {
/// This parameter checks if the current platform is web or not.
static bool get isWeb => kIsWeb;

/// This parameter calls the isDesktop and isMobile methods to detect if the current platform is desktop or web
/// This parameter calls the isDesktop and isMobile methods to detect if the current platform is desktop or web.
static bool get isDesktopOrWeb => isDesktop || isWeb;

/// Check if the platform on which the code is running is iOS
/// Check if the platform on which the code is running is iOS.
static bool get isIOS => defaultTargetPlatform == TargetPlatform.iOS;

/// Check if the platform on which the code is running is Android
/// Check if the platform on which the code is running is Android.
static bool get isAndroid => defaultTargetPlatform == TargetPlatform.android;

/// Check if the platform on which the code is running is Fuchsia
/// Check if the platform on which the code is running is Fuchsia.
static bool get isFuchsia => defaultTargetPlatform == TargetPlatform.fuchsia;

/// Check if the platform on which the code is running is Windows
/// Check if the platform on which the code is running is Windows.
static bool get isWindows => defaultTargetPlatform == TargetPlatform.windows;

/// Check if the platform on which the code is running is Linux
/// Check if the platform on which the code is running is Linux.
static bool get isLinux => defaultTargetPlatform == TargetPlatform.linux;

/// Check if the platform on which the code is running is macOS
/// Check if the platform on which the code is running is macOS.
static bool get isMacOS => defaultTargetPlatform == TargetPlatform.macOS;

/// Check if the device has enabled Dark Mode
/// Check if the device has enabled Dark Mode.
static bool get isDarkMode {
var brightness =
SchedulerBinding.instance.platformDispatcher.platformBrightness;
return brightness == Brightness.dark;
}

/// Check if the device has Light Mode
/// Check if the device has Light Mode.
static bool get isLightMode {
var brightness =
SchedulerBinding.instance.platformDispatcher.platformBrightness;
return brightness == Brightness.light;
}

/// Returns the type of theme applied to the device
/// Returns the type of theme applied to the device.
static DeviceTheme get theme =>
isLightMode ? DeviceTheme.light : DeviceTheme.dark;
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: platform_detail
description: A lightweight library to obtain details of the current platform in a much more complete and simple way.
version: 3.0.1
version: 3.1.0
homepage: https://github.com/vicajilau/platform_detail

environment:
Expand Down

0 comments on commit 145aba9

Please sign in to comment.