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

A new Flutter Plugin That Allow User to get call detail.

example/lib/main.dart

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

import 'package:flutter/services.dart';
import 'package:callplugin/callplugin.dart';
import 'package:permission_handler/permission_handler.dart';

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

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

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

class _MyAppState extends State<MyApp> {
  TextEditingController _phoneNumberController = TextEditingController();
  String _platformVersion = 'Call Detail Will Display Here';
  final _callpluginPlugin = Callplugin();

  Future<void> getCallDetail() async {
    String platformVersion = "";

    //Permission
    PermissionStatus readCallDetail = await Permission.phone.request();
    if (readCallDetail == PermissionStatus.granted) {
      platformVersion = (await _callpluginPlugin
          .getPlatformVersion(_phoneNumberController.text))!;
    } else {
      print("Not Granted Granted");
    }

    if (!mounted) return;

    setState(() {
      _platformVersion = platformVersion;
    });
  }

  Future<void> openDial() async {
    //Permission
    PermissionStatus readCallDetail = await Permission.phone.request();
    if (readCallDetail == PermissionStatus.granted) {
      _callpluginPlugin.openDial(_phoneNumberController.text);
    } else {
      print("Not Granted Granted");
    }
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        home: Scaffold(
      appBar: AppBar(
        title: Text('Phone Call App'),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Padding(
              padding: EdgeInsets.symmetric(horizontal: 20.0),
              child: TextField(
                controller: _phoneNumberController,
                decoration: const InputDecoration(
                  labelText: 'Phone Number',
                ),
              ),
            ),
            const SizedBox(height: 20.0),
            ElevatedButton(
              onPressed: () {
                String phoneNumber = _phoneNumberController.text;
                openDial();
              },
              child: const Text('Call'),
            ),
            const SizedBox(height: 20.0),
            ElevatedButton(
              onPressed: () {
                getCallDetail();
              },
              child: Text('Get Call Detail'),
            ),
            const SizedBox(height: 20.0),
             Text(_platformVersion),
          ],
        ),
      ),
    ));
  }
}
0
likes
0
pub points
0%
popularity

Publisher

unverified uploader

A new Flutter Plugin That Allow User to get call detail.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, flutter_web_plugins, plugin_platform_interface

More

Packages that depend on callplugin