monorepo/dialer/packages/mobile_number
Florian Griffon be20139cc4
All checks were successful
/ mirror (push) Successful in 4s
feat: Icon and name of the app changed to match Icing Dialer (#23)
Reviewed-on: icing/G-EIP-700-TLS-7-1-eip-stephane.corbiere#23
Co-authored-by: Florian Griffon <florian.griffon@epitech.eu>
Co-committed-by: Florian Griffon <florian.griffon@epitech.eu>
2025-01-12 12:39:37 +00:00
..
android add of sim changes 2024-11-28 20:57:58 +00:00
example feat: Icon and name of the app changed to match Icing Dialer (#23) 2025-01-12 12:39:37 +00:00
ios add of sim changes 2024-11-28 20:57:58 +00:00
lib add of sim changes 2024-11-28 20:57:58 +00:00
res/values add of sim changes 2024-11-28 20:57:58 +00:00
test add of sim changes 2024-11-28 20:57:58 +00:00
CHANGELOG.md add of sim changes 2024-11-28 20:57:58 +00:00
LICENSE add of sim changes 2024-11-28 20:57:58 +00:00
local.properties add of sim changes 2024-11-28 20:57:58 +00:00
pubspec.yaml add of sim changes 2024-11-28 20:57:58 +00:00
README.md add of sim changes 2024-11-28 20:57:58 +00:00
sample1.png add of sim changes 2024-11-28 20:57:58 +00:00

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

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
      }
    });

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