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

GitHub 儲存庫matszafraniec/flutter_device_region

flutter_device_region

一個使用平台特定 API 返回 SIM 國家代碼的 Flutter 插件。支援 iOS 和 Android。

flutter_device_region 專案封面
星標
7
分支
9
最近推送(UTC)
2024年4月24日
專案狀態
未封存

原始 README

以下為英文專案原文快照,最新內容請造訪 GitHub。

device_region

A Flutter plugin which uses platform-specific API to return a SIM country code. Supports iOS and Android.

Installation

In your Flutter project, in pubspec.yaml file add the dependency:

dependencies:
  device_region: ^1.4.0

Usage example

Import device_region.dart package.

import 'package:device_region/device_region.dart';
Get SIM country code

Call getSIMCountryCode method to receive SIM country code.

await DeviceRegion.getSIMCountryCode();
Android:

Using TelephonyManager class:

Returns simCountryIso if available. Otherwise, it should return networkCountryIso.

In case the value cannot be retrieved or an error occurs, null value will be returned

iOS:
iOS 16.0 and higher

Due to deprecated properties in CTTelephonyNetworkInfo class, plugin uses Locale class and returns Locale.current.region.identifier.

iOS up to 16.0

Using CTTelephonyNetworkInfo class:

Returns isoCountryCode if available.

In case the value cannot be retrieved or an error occurs, null value will be returned

Important notes

  • While call getSIMCountryCode on iOS (up to 16.0), it returns proper country code and can throw error log in debugger as below:
[Client] Updating selectors after delegate addition failed with: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service with pid 91 named com.apple.commcenter.coretelephony.xpc was invalidated from this process." UserInfo={NSDebugDescription=The connection to service with pid 91 named com.apple.commcenter.coretelephony.xpc was invalidated from this process.}

It's well known bug on iOS and it does not affect the operation of the application.

  • Method returns null in case if for some reason it was not possible to retrieve the information from the SIM slot. So it will return null i.e on iOS simulators and devices without SIM card inserted.

  • On iOS, it only works from 12.0 and above. For lower versions it will return null.

Mateusz Szafraniec GitHub avatar
GitHub 作者

Mateusz Szafraniec ↗

Programmer enthusiastic in mobile development.

Gdansk, Poland官方網站 ↗
語言CMakeC++DartRubyKotlinSwiftCObjective-C

此儲存庫發佈的套件

使用的依賴

依賴清單 3 項

  • flutter{"sdk":"flutter"}
  • flutter_test開發依賴{"sdk":"flutter"}
  • flutter_lints開發依賴^1.0.0

如何選擇適合專案的儲存庫?

先依使用情境篩選,再比較專案活躍情況,最後到原始儲存庫確認使用要求。

  1. 透過儲存庫名稱、作者或描述搜尋,再依技術分類縮小範圍。
  2. 綜合星標、分支與最近推送比較專案;星標反映社群關注,不保證品質。
  3. 使用前在 GitHub 確認 README、授權條款與 Issues。

來源與維護

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗