flutter_telephony

get telephony info:

Android:based on TelephonyManager

iOS:based on CoreTelephony

Installation

//pub
dependencies:
  flutter_telephony: any

//import
dependencies:
  flutter_telephony:
    git:
      url: git://github.com/aliazimoshan/flutter_telephony.git

Android

cellInfo || cellLocation(If cellInfo return null ,this package fill cellLocation, in old android SDK this might happened)

Requires permission:android.permission.ACCESS_FINE_LOCATION

dataNetworkType

Requires permission:android.permission.READ_PHONE_STATE

deviceSoftwareVersion

Requires permission:android.permission.READ_PHONE_STATE

IMEI(International Mobile Equipment Identity)(imei)

Requires permission:android.permission.READ_PHONE_STATE

isDataEnabled

Requires one of the following permissions:

android.permission.ACCESS_NETWORK_STATE

android.permission.MODIFY_PHONE_STATE

line1Number

Requires one of the following permissions:

android.permission.READ_PHONE_STATE

android.permission.READ_SMS

android.permission.READ_PHONE_NUMBERS

MEID (Mobile Equipment Identifier)(meid)

Requires permission:android.permission.READ_PHONE_STATE

Network Access Identifier (NAI)

Requires permission:android.permission.READ_PHONE_STATE

<manifest
    ...
    xmlns:tools="http://schemas.android.com/tools" >
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
    <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.MODIFY_PHONE_STATE"/>
    <uses-permission android:name="android.permission.READ_SMS"/>
    <uses-permission android:name="android.permission.READ_PHONE_NUMBERS"/>
    ...
</manifest>

iOS

Getting Information About the Cellular Service Provider

var allowsVOIP: Bool

Indicates if the carrier allows making VoIP calls on its network.

var carrierName: String?

The name of the user’s home cellular service provider.

var isoCountryCode: String?

The ISO country code for the user’s cellular service provider.

var mobileCountryCode: String?

The mobile country code (MCC) for the user’s cellular service provider.

var mobileNetworkCode: String?

The mobile network code for the user’s cellular service provider.

Example

import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:flutter_telephony/flutter_telephony.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  FlutterTelephony _info;

  @override
  void initState() {
    super.initState();
    getFlutterTelephony();
  }

  Future<void> getFlutterTelephony() async {
    FlutterTelephony info;
    try {
      info = await FltFlutterTelephony.info;
    } on PlatformException {}

    if (!mounted) return;

    setState(() {
      _info = info;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Text('Phone Number: ${_info?.line1Number}\n'),
        ),
      ),
    );
  }
}

Libraries

flutter_telephony