Search categories, packages and repositories

mobile_number cover
Package detailsv3.0.0

mobile_number

A Flutter plugin for fetching the device's mobile number or list sim cards data

Android
30-day downloads
4.3K
Likes
112
Pub points
140

Install package

flutter pub add mobile_number

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

The mobile_number package is a Flutter plugin that enables access to the device's mobile number or SIM card information on Android. It provides a simple API to retrieve the phone number associated with the device or details about installed SIM cards. Designed specifically for Android, it leverages native Android APIs to extract this data securely. The plugin does not support iOS due to platform limitations. Developers can integrate it into apps requiring user phone number identification or SIM-related functionality.

Use cases

  • Fetching device's primary phone number
  • Retrieving SIM card details
  • User authentication via phone number
  • Device identification in mobile apps
  • SIM card status monitoring

Key features

  • Android-only support
  • Simple API for phone number retrieval
  • Access to SIM card data
  • Secure native integration
  • Lightweight and easy to implement

Suitable for

  • Android-focused mobile apps
  • Phone number-based authentication
  • SIM card information tools
  • Device-specific app features
  • Apps needing basic telephony data

Considerations

  • Not available on iOS
  • Requires runtime permissions
  • Limited to Android devices
  • Privacy-sensitive data access
  • May not work on all Android models

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

mobile_number

This is a FLutter Plugin to get the device mobile number.

Note: It works for Android only because getting mobile number of sim card is not supported in iOS.
Note: If the mobile number is not pre-exist on sim card it will not return te phone number.

Installation

Link on Flutter plugins

https://pub.dev/packages/mobile_number

Note:

if you still using depecated FlutterActivty on MainActivity.java which is import of

  • import io.flutter.app.FlutterActivity;

not

  • import io.flutter.embedding.android.FlutterActivity;

then you need to add the following to your MainActivity.java

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        MobileNumberPlugin.registerWith(registrarFor("com.amorenew.mobile_number.MobileNumberPlugin()"));
    }

Usage

Check Phone Permission

await MobileNumber.hasPhonePermission

Request Phone Permission

await MobileNumber.requestPhonePermission

Listen to widget resume after Phone Permission request
      if (isPermissionGranted) {
        //Get mobile number
      } else {
        //Request Phone Permission
      }
    });
Alternative Phone Permission

permission_handler has a better implementation of device general permissions.

A simple example would be:

var status = await Permission.phone.status;
if (!status.isGranted) {
  status = await Permission.phone.request();
}

if (!status.isGranted) {
  // return or throw some error
}

return await MobileNumber.mobileNumber;

Get first sim card number
    final String mobileNumber = await MobileNumber.mobileNumber;
    return mobileNumber;
  }
Get List of sim cards for dual sim cards
    final List<SimCard> simCards = await MobileNumber.getSimCards;
    return simCards;
  }

alt text

Categories

Source repository

Projects using this package

No data available yet.