搜尋套件、儲存庫與 APP 分類

client_information 封面
套件詳情v2.2.0

client_information

這是一個讓您可以取得應用程式客戶端基本資訊的外掛程式。使用簡單,並支援不同平台(Android、iOS 與 Web)。

AndroidiOSWeb
近 30 天下載
5450
喜歡數
53
Pub 分數
140

安裝套件

flutter pub add client_information

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

client_information 套件為 Flutter 應用程式中的基本客戶端裝置資訊提供便捷存取。支援 Android、iOS 與 Web 平台,讓開發者能夠取得設備型號、作業系統版本與平台類型等重要資訊。設計簡潔,透過直覺的 API 與現有專案無縫整合。適用於分析、除錯或個人化功能,確保在不同環境中的一致行為。

適用情境

  • 設備分析
  • 使用者輪廓
  • 除錯與故障排除
  • 個性化使用者體驗
  • 跨平台應用開發

主要特色

  • 跨平台支援(Android、iOS、Web)
  • 簡單直覺的 API
  • 取得裝置型號與作業系統資訊
  • 輕量且快速
  • 跨平台資料一致

適合對象

  • 開發跨平台應用的開發者
  • 需要設備級洞察的團隊
  • 需要使用者裝置上下文的應用程式
  • 分析與監控工具
  • Web 與行動混合應用程式

使用建議

  • Android 和 iOS 需要適當的權限
  • 僅限基本設備資訊
  • 收集資料時需要符合隱私合規要求
  • 無即時更新
  • 依賴於平台特定的實作

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

Client Information

This is a plugin that lets you get basic information from your application's client. It's easy to use and supports different platforms (Android, iOS, and Web). There are four different information types: "application information", "software information", "operating system information", and "device information".

Pub License: MIT

iOS screenshot

Android screenshot

Web screenshot

Information Types

There are 4 different types:

  1. Application Information
  2. Software Information
  3. Operating System Information
  4. Device Information
Application Information

Application information is all about the application you build. And notice that applicationId is not supported for web applications.

Attribute iOS Android Web
applicationId
String
⭕
bundleIdentifier
⭕
package name
❌
default: application name
applicationType
String (app/web)
⭕ ⭕ ⭕
applicationName
String
⭕ ⭕ ⭕
applicationVersion
String
⭕ ⭕ ⭕
applicationBuildCode
String
⭕ ⭕ ⭕

Software Information

"Software" stands for the "software" that runs your application, such as "Operating System" for iOS/Android projects or "Browser" for web projects.

Attribute iOS Android Web
softwareName
String
⭕
OS name
⭕
OS name
⭕
Browser name
softwareVersion
String
⭕
OS version
⭕
OS version
⭕
Browser version

Operating System Information

OS information will show you the OS's name and version. Notice: Web projects may not get this information if the browser's user-agent doesn't contain any information about the operating system.

Attribute iOS Android Web
osName
String
⭕
OS name
⭕
OS name
⚠️
OS name
(*unknown possible)
osVersion
String
⭕
OS version
⭕
OS version
⚠️
OS Version
(*unknown possible)
osVersionCode
String
⭕
iOS version(number)
⭕
Android API level
⚠️
OS Version(number)
(*unknown: -1)

Device Information

The device information will display device's ID and name. Note that web projects don't support real deviceId, so they will use the package uuid to generate a unique string and save to the browser's cookie.

Attribute iOS Android Web
deviceId
String
⭕ ⭕ ⭕
deviceName
String
⭕ ⭕ ❌
default: osName osVersion / browserName browserVersion
(e.g. iOS 14 / Chrome 88.0)

Getting Started

In the pubspec.yaml of your flutter project, add the following dependency:

dependencies:
  ...
  client_information: ^2.2.0

In your project add the following import:

import 'package:client_information/client_information.dart';

Then, you can get information like this:

// Get client information
ClientInformation info = await ClientInformation.fetch();

print(info.deviceId); // EA625164-4XXX-XXXX-XXXXXXXXXXXX
print(info.osName); // iOS

Decoration

Starting from version 2.1.0, you can customize some information by passing the decorators. Like below:

var information = await ClientInformation.fetch(
      // you can pass decorators to decoration the value before it return.
      decorators: ClientInformationDecorators(
        deviceId: (oriInfo, value) =>
            'prefix-$value-${oriInfo.applicationName}',
      ),
    );

Or, you can use extension method like this:

var information = await ClientInformation.fetch();
print('Original DeviceId: ${information.deviceId}');
// Original DeviceId: EA625164-4XXX-XXXX-XXXXXXXXXXXX

var decoratedInfo = information.decoration(deviceId: (oriInfo, value) => '$value-some-suffix-string-here');
print('Decorated DeviceId: ${decoratedInfo.deviceId}');
// Decorated DeviceId: EA625164-4XXX-XXXX-XXXXXXXXXXXX-some-suffix-string-here

Mock Data for Test

Starting from version 1.0.2, you can mock data or enable "mockMode" to facilitate testing. Here is how to set it up:


In your test file:

setUp(() async {
  // Change to "MockMode" and set the default data you need.
  ClientInformation.mockOn(
      deviceId: 'mock_device_id', osName: 'MyCustomOS');
});

tearDown(() {
  // Close the "MockMode" in tearDown method
  ClientInformation.mockOff();
});

// Run your test
test('`deviceId` will be "mock_device_id"', () async {
  ClientInformation info = await ClientInformation.fetch();
  expect(info.deviceId, 'mock_device_id');
});

所屬分類

依賴

依賴清單 1 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。