fetch_mobile_numbers 0.0.1 copy "fetch_mobile_numbers: ^0.0.1" to clipboard
fetch_mobile_numbers: ^0.0.1 copied to clipboard

PlatformAndroid

A Flutter plugin to fetch mobile number and other information related to it from the device

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';
import 'package:fetch_mobile_numbers/sim_card/sim_card_info.dart';
import 'package:flutter/services.dart';
import 'package:fetch_mobile_numbers/fetch_mobile_numbers.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  List<SimCard> _mobileNumbers = [];
  final _fetchMobileNumbersPlugin = FetchMobileNumbers();

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

  Future<void> initPlatformState() async {
    List<SimCard>? mobileNumbers;
    try {
      mobileNumbers =
          await _fetchMobileNumbersPlugin.getMobileNumbers();
    } on PlatformException {
      mobileNumbers = [];
    }

    if (!mounted) return;

    setState(() {
      _mobileNumbers = mobileNumbers ?? [];
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              if(_mobileNumbers.isNotEmpty && _mobileNumbers.length == 1)
              Text('${_mobileNumbers[0].toString()}\n'),
              if(_mobileNumbers.isNotEmpty && _mobileNumbers.length == 2)
                Text('${_mobileNumbers[0].toString()}\n'),
              if(_mobileNumbers.isNotEmpty && _mobileNumbers.length == 2)
                Text('${_mobileNumbers[1].toString()}\n'),
              if(_mobileNumbers.isEmpty)
                const Text('Unble to Detect Sim Numbers\n'),
            ],
          ),
        ),
      ),
    );
  }
}
3
likes
140
points
22
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter plugin to fetch mobile number and other information related to it from the device

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on fetch_mobile_numbers

Packages that implement fetch_mobile_numbers