get telephony info:
Android:based on TelephonyManager
iOS:based on CoreTelephony
ENGLISH | 中文
//pub
dependencies:
flt_telephony_info: any
//import
dependencies:
flt_telephony_info:
git:
url: git://github.com/RandyWei/flt_telephony_info.git
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.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>
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.
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:flt_telephony_info/flt_telephony_info.dart';
void main() => runApp(MyApp());
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
TelephonyInfo _info;
@override
void initState() {
super.initState();
getTelephonyInfo();
}
Future<void> getTelephonyInfo() async {
TelephonyInfo info;
try {
info = await FltTelephonyInfo.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'),
),
),
);
}
}