flutter_sim_country_code_plus

pub package license: MIT

A Flutter plugin that reads the ISO 3166-1 alpha-2 country code from the device's SIM card. The SIM country is often a more reliable region signal than the system locale, which only reflects the phone's language setting.

This is a maintained fork of flutter_sim_country_code, updated for the Android v2 plugin embedding and modern Flutter (3.3+ / Dart 3) so it keeps building on current toolchains.

Platform support

Platform Supported Source
Android ✅ (minSdk 21) TelephonyManager.getSimCountryIso()
iOS ✅ (12.0+) CoreTelephonyCTCarrier.isoCountryCode

Installation

Add the dependency to your pubspec.yaml:

dependencies:
  flutter_sim_country_code_plus: ^0.2.0

Then fetch it:

flutter pub get

Usage

import 'package:flutter_sim_country_code_plus/flutter_sim_country_code_plus.dart';

Future<void> printSimCountry() async {
  final String? countryCode = await FlutterSimCountryCodePlus.simCountryCode;
  // e.g. "US" on Android (upper-case), "us" on iOS
  print('SIM country: $countryCode');
}

simCountryCode returns a Future<String?>. It resolves to null, or throws a PlatformException, when there is no SIM or the country cannot be determined — so guard for it:

try {
  final code = await FlutterSimCountryCodePlus.simCountryCode;
  if (code != null) {
    // use code
  }
} on PlatformException {
  // no SIM / country unavailable
}

API

Member Returns Description
FlutterSimCountryCodePlus.simCountryCode Future<String?> ISO 3166-1 alpha-2 country code of the SIM, or null if unavailable.

Notes

  • No runtime permission requiredgetSimCountryIso() (Android) and CTCarrier (iOS) do not need the phone/telephony permission.
  • iOS 16+: Apple deprecated CTCarrier; on iOS 16 and later isoCountryCode may return nil (or a placeholder). This is an OS limitation with no public replacement API — treat null as "unknown" and fall back to the device locale if you need a value.
  • The value reflects the SIM country, which can differ from the current network/roaming country and from the device locale.

Migrating from flutter_sim_country_code

  1. Replace the dependency name with flutter_sim_country_code_plus.
  2. Update imports to package:flutter_sim_country_code_plus/flutter_sim_country_code_plus.dart.
  3. Rename the API class FlutterSimCountryCodeFlutterSimCountryCodePlus.

Credits

Originally created by Alexandru Tuca as flutter_sim_country_code. This fork continues it with Android v2 embedding and modern Flutter support.

License

MIT