flt_telephony_info 0.1.3 flt_telephony_info: ^0.1.3 copied to clipboard
A new Flutter plugin , get telephony info ,based on TelephonyManager in Android and based on CoreTelephony in iOS
flt_telephony_info #
get telephony info:
Android:based on TelephonyManager
iOS:based on CoreTelephony
ENGLISH | 中文 #
Installation #
//pub
dependencies:
flt_telephony_info: any
//import
dependencies:
flt_telephony_info:
git:
url: git://github.com/RandyWei/flt_telephony_info.git
Android #
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>
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: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'),
),
),
);
}
}