Skip to content
pubscout

device_region

1.4.0, released 3 years ago by matszafraniec.xyz

A Flutter plugin to retrieve the SIM country code using platform-specific APIs.

WASM-ready
$ flutter pub add device_region
Source repository

What it does

It accesses native platform APIs to retrieve the SIM country code. On Android, it uses TelephonyManager. On iOS, it uses either Locale or CTTelephonyNetworkInfo depending on the iOS version.

AI-written summary of version 1.4.0, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need to retrieve the SIM card country code on Android or iOS.
  • You want a straightforward imperative method call to get the region ISO code.

Skip it when

  • You are running on iOS simulators or devices without a SIM card where it will return null.
  • You need deep locale or language translation management rather than just the SIM country code.

Strengths

  • Simple API with a single main method: getSIMCountryCode.
  • Handles deprecated iOS APIs by falling back to Locale for iOS 16.0 and higher.

Weaknesses

  • Returns null on iOS simulators and devices without a SIM card.
  • Windows and Linux support is very basic and simply returns null instead of throwing an exception.

Setup

Kind
Plugin (native code)
Effort
Low
Code generation
No
Direct dependencies
0

No extra native setup or permissions are documented beyond adding the dependency.

import 'package:device_region/device_region.dart';

Future<void> getCountry() async {
  String? simCountryCode = await DeviceRegion.getSIMCountryCode();
}

Alternatives

Packages that do the same job and could replace device_region.

  • devicelocale

    It provides the device locale and language settings if you need general locale information rather than strictly the SIM country code.