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