Skip to content

Commit

Permalink
Release 3.2.1 version
Browse files Browse the repository at this point in the history
  • Loading branch information
vicajilau committed Aug 6, 2023
1 parent 2edd290 commit bcfbb28
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 23 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 3.2.1
* Renamed productName by deviceInfo().
* Updated documentation.

## 3.2.0
* Added productName.
* Updated documentation.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ if (PlatformDetail.isMacOS) {
### Get a device description
If you need more detailed information about the device and operating system it is running on. In web you will get information from the browser:
```dart
final descriptionDevice = await PlatformDetail.productName;
final descriptionDevice = await PlatformDetail.deviceInfo();
```

### Light/Dark Mode
Expand Down
40 changes: 19 additions & 21 deletions lib/src/platform_detail.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,26 +75,6 @@ class PlatformDetail {
/// 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.
static bool get isDarkMode {
var brightness =
SchedulerBinding.instance.platformDispatcher.platformBrightness;
return brightness == Brightness.dark;
}

/// 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.
static DeviceTheme get theme =>
isLightMode ? DeviceTheme.light : DeviceTheme.dark;
}

extension DevicesName on PlatformDetail {
/// This parameter returns the industrial name and OS version of the current device.
/// EXAMPLES:
/// Android: Android 9 (SDK 28), Xiaomi Redmi Note 7
Expand All @@ -103,7 +83,7 @@ extension DevicesName on PlatformDetail {
/// Linux: Fedora 17 (Beefy Miracle)
/// Windows: Windows 10 Home (1903)
/// MacOS: macOS 13.5, MacBook Pro
static Future<String> get productName async {
static Future<String> deviceInfo() async {
if (PlatformDetail.isWeb) {
final info = await DeviceInfoPlugin().webBrowserInfo;
return '${info.browserName.name} (${info.appVersion})';
Expand Down Expand Up @@ -142,4 +122,22 @@ extension DevicesName on PlatformDetail {
return "${info.productName}(${info.releaseId})";
}
}

/// 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.
static bool get isLightMode {
var brightness =
SchedulerBinding.instance.platformDispatcher.platformBrightness;
return brightness == Brightness.light;
}

/// 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.2.0
version: 3.2.1
homepage: https://github.com/vicajilau/platform_detail

environment:
Expand Down

0 comments on commit bcfbb28

Please sign in to comment.