phone_number_resolver 0.0.3
phone_number_resolver: ^0.0.3 copied to clipboard

A Flutter plugin for resolving user phone number from Android telephony manager. Currently supports on only Android.

example/lib/main.dart

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

import 'package:flutter/services.dart';
import 'package:phone_number_resolver/phone_number_resolver.dart';

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

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

class _MyAppState extends State<MyApp> {
  String _phoneNumber = 'Unknown';

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

  // Platform messages are asynchronous, so we initialize in an async method.
  _resolveNumber() {
    PhoneNumberResolver.resolveNumber().then((x){
      setState(() {
        _phoneNumber = x;
      });
    }).catchError((e)=>
        print(e)
    );
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Column(
            children: <Widget>[
              Text('Running on: $_phoneNumber\n'),
              RaisedButton(
                onPressed: _onPressed,
              ),
            ],
          ),
        ),
      ),
    );
  }

  void _onPressed() {
    _resolveNumber();
  }
}
1
likes
80
pub points
0%
popularity

A Flutter plugin for resolving user phone number from Android telephony manager. Currently supports on only Android.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (LICENSE)

Dependencies

flutter

More

Packages that depend on phone_number_resolver