sim_phone_plus

A modern Flutter plugin that fetches SIM card phone numbers and carrier details with graceful permission handling, device compatibility checks, and a developer-friendly API.

Features

  • Fetch SIM Details: Retrieve phone number, carrier name, country ISO, and SIM slot index.
  • Graceful Permissions: Automatically checks for READ_PHONE_STATE permission on Android and provides helper methods to request it.
  • Platform Safe: Returns structured "not supported" responses on iOS and web, ensuring your app never crashes.
  • Null-Safe & Typed: Clean, modern, and null-safe Dart code.

Platform Support

Platform Supported
Android
iOS
Web
macOS
Windows
Linux

Installation

Add sim_phone_plus to your pubspec.yaml dependencies:

dependencies:
  sim_phone_plus: ^0.0.1 # Replace with the latest version

Then, run flutter pub get.

Permissions

Android

This plugin requires the READ_PHONE_STATE permission. Add the following line to your android/app/src/main/AndroidManifest.xml:

<uses-permission android:name="android.permission.READ_PHONE_STATE"/>

Usage

Import the package and create an instance of the plugin:

import 'package:sim_phone_plus/sim_phone_plus.dart';

final simPhonePlus = SimPhonePlus();

Check for Permissions and Get SIM Info

It's best practice to check for permissions before trying to get SIM information.

Future<void> _getSimInfo() async {
  bool? hasPermission = await simPhonePlus.hasPermission();
  if (hasPermission == false) {
    await simPhonePlus.requestPermission();
  }

  final List<SimPhoneInfo> simInfo = await simPhonePlus.getSimPhoneInfo();
  // Use the simInfo list...
}

Example

Here is a snippet from the example app, which displays a list of SIM cards.

ListView.builder(
  shrinkWrap: true,
  itemCount: _simPhoneInfo.length,
  itemBuilder: (context, index) {
    final sim = _simPhoneInfo[index];
    return ListTile(
      title: Text('SIM Card ${sim.slotIndex}'),
      subtitle: Text(
          'Carrier: ${sim.carrierName}\n'
          'Number: ${sim.phoneNumber ?? 'N/A'}\n'
          'Country ISO: ${sim.countryIso}\n'
          'Message: ${sim.message}'
      ),
    );
  },
)

Screenshots

Before Permission After Permission
Before Permission After Permission

Note: The included screenshots are placeholders. Replace them with your own app screenshots.

Contributing

Contributions are welcome! If you find a bug or have a feature request, please open an issue. If you want to contribute code, please open a pull request.