{"id":16558135,"url":"https://github.com/vicajilau/platform_detail","last_synced_at":"2025-07-27T13:09:04.031Z","repository":{"id":46589407,"uuid":"493531365","full_name":"vicajilau/platform_detail","owner":"vicajilau","description":"A lightweight Dart package for retrieving platform details in a simple and optimized way. Supports mobile, desktop, and web.","archived":false,"fork":false,"pushed_at":"2025-06-02T08:47:12.000Z","size":564,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-02T19:45:19.719Z","etag":null,"topics":["cross-platform","dart","device-info","flutter","os-detection","platform","platform-detection"],"latest_commit_sha":null,"homepage":"https://pub.dev/packages/platform_detail","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vicajilau.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-05-18T06:09:13.000Z","updated_at":"2025-06-02T08:47:16.000Z","dependencies_parsed_at":"2023-12-11T08:25:47.557Z","dependency_job_id":"a221d620-55d1-4adc-ba93-f0e663bdf63a","html_url":"https://github.com/vicajilau/platform_detail","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/vicajilau/platform_detail","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vicajilau%2Fplatform_detail","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vicajilau%2Fplatform_detail/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vicajilau%2Fplatform_detail/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vicajilau%2Fplatform_detail/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vicajilau","download_url":"https://codeload.github.com/vicajilau/platform_detail/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vicajilau%2Fplatform_detail/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267361717,"owners_count":24074973,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-27T02:00:11.917Z","response_time":82,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cross-platform","dart","device-info","flutter","os-detection","platform","platform-detection"],"created_at":"2024-10-11T20:09:41.044Z","updated_at":"2025-07-27T13:09:04.026Z","avatar_url":"https://github.com/vicajilau.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://pub.dev/packages/platform_detail\"\u003e\n    \u003cimg src=\"https://raw.githubusercontent.com/vicajilau/platform_detail/main/.github/assets/platform_detail.png\" height=\"200\" alt=\"Platform Detail Logo\"\u003e\n  \u003c/a\u003e\n  \u003ch1 align=\"center\"\u003ePlatform Detail\u003c/h1\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://pub.dev/packages/platform_detail\"\u003e\n    \u003cimg src=\"https://img.shields.io/pub/v/platform_detail?label=pub.dev\u0026labelColor=333940\u0026logo=dart\" alt=\"Pub Version\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/vicajilau/platform_detail/actions/workflows/dart_analyze_unit_test.yml\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/actions/workflow/status/vicajilau/platform_detail/dart_analyze_unit_test.yml?branch=main\u0026label=CI\u0026labelColor=333940\u0026logo=github\" alt=\"CI Status\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/vicajilau/platform_detail/actions/workflows/publish_pub_dev.yml\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/actions/workflow/status/vicajilau/platform_detail/publish_pub_dev.yml?label=CD\u0026labelColor=333940\u0026logo=github\" alt=\"CD Status\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://codecov.io/gh/vicajilau/platform_detail\"\u003e\n    \u003cimg src=\"https://img.shields.io/codecov/c/github/vicajilau/platform_detail?logo=codecov\u0026logoColor=fff\u0026labelColor=333940\" alt=\"Code Coverage\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n## About\n\n**Platform Detail** is a lightweight and developer-friendly Flutter package that makes platform detection easier, more complete, and cross-platform.  \nIt provides a unified and consistent API for checking the platform your app is running on — **including web**, something that native Flutter classes like [`TargetPlatform`](https://api.flutter.dev/flutter/foundation/TargetPlatform.html) and `Platform` from `dart:io` don't currently support.\n\n\u003e ⚠️ Flutter’s native `Platform` and `TargetPlatform` do **not** provide support for detecting web, which can be a limitation in universal apps.  \n\u003e ✅ `platform_detail` addresses this limitation by introducing a simple and intuitive API that includes web detection out of the box.\n\n## ✅ Why Use This Package?\n\n- ✅ Unified API across all platforms (including web).\n- ✅ Clear separation between **platform type** and **platform group**.\n- ✅ Singleton behavior via factory constructor.\n- ✅ No need to manually check `kIsWeb` or rely on partial solutions.\n- ✅ Detect private and public IP addresses.\n- ✅ Detect device theme (light or dark).\n\n## Getting Started\n\nThe recommended way to use the library is to call the static members of the [PlatformDetail] class.  \nThanks to a factory constructor, multiple instances are not created — a singleton is used internally.\n\n---\n\n## 🔍 Basic Usage\n\n### ✔️ Detecting Platform Type\n\n```dart\nimport 'package:platform_detail/platform_detail.dart';\n\nvoid main() {\n  PlatformType platform = PlatformDetail.currentPlatform;\n  print('This platform is: $platform'); // e.g., PlatformType.android\n}\n```\n\n---\n\n### 🌐 Why use `PlatformType`?\n\nIf you only rely on `TargetPlatform`, you’ll miss web support.\n\n```dart\nvoid main() {\n  // Native TargetPlatform doesn't detect web:\n  if (defaultTargetPlatform == TargetPlatform.android) {\n    // OK for Android\n  } else if (kIsWeb) {\n    // Web has to be checked manually\n  }\n}\n```\n\nWith `PlatformDetail`, the check is unified:\n\n```dart\nvoid main() {\n  if (PlatformDetail.isWeb) {\n    print('Web detected ✔️');\n  }\n}\n```\n\n---\n\n### 🔎 Group-based Detection\n\nCheck whether the current platform belongs to a broader category:\n\n```dart\nvoid main() {\n  if (PlatformDetail.isMobile) {\n    print('Mobile platform');\n  }\n\n  if (PlatformDetail.isDesktop) {\n    print('Desktop platform');\n  }\n\n  if (PlatformDetail.isDesktopOrWeb) {\n    print('Desktop or Web platform');\n  }\n}\n```\n\nOr use the `PlatformGroup` enum directly:\n\n```dart\nvoid main() {\n  switch (PlatformDetail.currentGroupPlatform) {\n    case PlatformGroup.mobile:\n      print('Mobile');\n      break;\n    case PlatformGroup.web:\n      print('Web');\n      break;\n    case PlatformGroup.desktop:\n      print('Desktop');\n      break;\n  }\n}\n```\n\n---\n\n### 🎯 Detecting Specific Platforms\n\n```dart\nvoid main() {\n  if (PlatformDetail.isIOS) print('iOS');\n  if (PlatformDetail.isAndroid) print('Android');\n  if (PlatformDetail.isFuchsia) print('Fuchsia');\n  if (PlatformDetail.isWindows) print('Windows');\n  if (PlatformDetail.isLinux) print('Linux');\n  if (PlatformDetail.isMacOS) print('macOS');\n  if (PlatformDetail.isWeb) print('Web');\n}\n```\n\nOr create different cases through the enum with a switch:\n\n```dart\nvoid main() {\n  switch (PlatformDetail.currentPlatform) {\n    case PlatformType.android:\n      print('Android');\n    case PlatformType.iOS:\n      print('iOS');\n    case PlatformType.isFuchsia:\n      print('Fuchsia');\n    case PlatformType.Windows:\n      print('Windows');\n    case PlatformType.Linux:\n      print('Linux');\n    case PlatformType.macOS:\n      print('macOS');\n    case PlatformType.Web:\n      print('Web');\n  }\n}\n```\n---\n\n### 🌐 Detecting IPs\n\nYou can detect the **private IP** of the device:\n\n```dart\nvoid main() async {\n  final List\u003cString\u003e privateIps = await PlatformDetail.getPrivateIp;\n}\n```\n\nYou can also detect the **public IP** of the device:\n\n```dart\nvoid main() async {\n  final String publicIp = await PlatformDetail.getPublicIp;\n}\n```\n\n\u003e ℹ️ No configuration is required for most platforms.  \n\u003e For **macOS**, you must add the following entry to both `DebugProfile.entitlements` and `ReleaseProfile.entitlements` files:\n\n```xml\n\u003ckey\u003ecom.apple.security.network.client\u003c/key\u003e\n\u003ctrue/\u003e\n```\n---\n\n### Get a device description\nIf you need more detailed information about the device and operating system it is running on.\n```dart\nvoid main() async {\n  final descriptionDevice = await PlatformDetail.deviceInfo();\n}\n```\nOr maybe you need an information string about the device info:\n```dart\nvoid main() async {\n  final descriptionDevice = await PlatformDetail.deviceInfoDetails();\n}\n```\nThis will return something like this:\n- Android: Android 9 (SDK 28), Xiaomi Redmi Note 7\n- iOS: iOS 13.1, iPhone 11 Pro Max iPhone\n- Web: Google Chrome (115.0.5790.170)\n- Linux: Fedora 17 (Beefy Miracle)\n- Windows: Windows 10 Home (1903)\n- MacOS: macOS 13.5, MacBook Pro\n---\n\n### Light/Dark Mode\nYou can detect too if the device is configured in light or dark mode:\n\n```dart\nvoid main() {\n  if (PlatformDetail.isLightMode) {\n    print('The current platform is configured with light mode');\n  }\n\n  if (PlatformDetail.isDarkMode) {\n    print('The current platform is configured with dark mode');\n  }\n}\n```\n\nAlso, you can use the [DeviceTheme] enum for this:\n\n```dart\nvoid main() {\n  if (PlatformDetail.theme == DeviceTheme.light) {\n    print('The current device is configured in light mode');\n  }\n\n  if (PlatformDetail.theme == DeviceTheme.dark) {\n    print('The current device is configured in dark mode');\n  }\n}\n```\n\n[PlatformDetail]: https://github.com/vicajilau/platform_detail/blob/master/lib/src/platform_detail.dart\n[PlatformGroup]: https://github.com/vicajilau/platform_detail/blob/master/lib/src/platform_group.dart\n[DeviceTheme]: https://github.com/vicajilau/platform_detail/blob/master/lib/src/device_theme.dart\n[PlatformType]: https://github.com/vicajilau/platform_detail/blob/master/lib/src/platform_type.dart","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvicajilau%2Fplatform_detail","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvicajilau%2Fplatform_detail","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvicajilau%2Fplatform_detail/lists"}