flt_telephony_info 0.1.3

  • Readme
  • Changelog
  • Example
  • Installing
  • 91

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

Other #

Home Page

Video Player Based On TxVodPlayer

0.1.3 #

  • fixed bug

0.1.2 #

  • Migrate to AndroidX

0.1.1 #

  • fixed bug

0.1.0 #

  • Get telephony info

example/README.md

flt_telephony_info_example #

Demonstrates how to use the flt_telephony_info plugin.

使用 #

//pub
dependencies:
  flt_telephony_info: ^lastest_version

//import
dependencies:
  flt_telephony_info:
    git:
      url: git://github.com/RandyWei/flt_telephony_info.git

Android #

根据需要添加以下其中权限

当前使用中的网络数据类型(dataNetworkType)需要权限:android.permission.READ_PHONE_STATE

设备的软件版本号(deviceSoftwareVersion)需要权限:android.permission.READ_PHONE_STATE

IMEI(International Mobile Equipment Identity)(imei)需要权限:android.permission.READ_PHONE_STATE

是否打开网络数据(isDataEnabled) 需要以下两个权限之一: android.permission.ACCESS_NETWORK_STATE android.permission.MODIFY_PHONE_STATE

手机号码(line1Number) 需要以下权限之一: android.permission.READ_PHONE_STATE android.permission.READ_SMS android.permission.READ_PHONE_NUMBERS

MEID (Mobile Equipment Identifier)(meid)需要权限:android.permission.READ_PHONE_STATE

Network Access Identifier (NAI) 需要权限: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>

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

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  flt_telephony_info: ^0.1.3

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:flt_telephony_info/flt_telephony_info.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
82
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
91
Learn more about scoring.

We analyzed this package on Nov 21, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.6.1
  • pana: 0.12.21
  • Flutter: 1.9.1+hotfix.6

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Format lib/flt_telephony_info.dart.

Run flutter format to format lib/flt_telephony_info.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.7 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test