flutter_phone_call_state 0.0.5 copy "flutter_phone_call_state: ^0.0.5" to clipboard
flutter_phone_call_state: ^0.0.5 copied to clipboard

This Flutter plugin allows you to track and manage phone call states on Android and iOS devices.

Table of Contents #


GitHub commit activity GitHub contributors GitHub Repo stars GitHub Workflow Status GitHub Pub Points Pub Popularity Pub Likes Pub Version Code Coverage


DESCRIPTION #

This Flutter plugin allows you to track and manage phone call states on Android and iOS devices. It helps you monitor the current state of a call (incoming, outgoing, accepted, or ended) and provides real-time updates.

Features #

  • Detects the current phone call status (incoming, answered, or ended).
  • Supports both Android and iOS platforms.
  • Provides real-time call state updates.
  • Simple and easy-to-use API.

Native Integration #

PAY ATTENTION #

  • In the iOS simulator doesn't work
  • The phone number is only obtainable on Android!

HOW TO INSTALL #

Flutter

dependencies:
  flutter:
    sdk: flutter
  flutter_phone_call_state: 0.0.5
copied to clipboard

android Permissions #

Android: Added permission on manifest

<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.READ_CALL_LOG" />
copied to clipboard

Warning: Adding READ_CALL_LOG permission, your app will be removed from the Play Store if you don't have a valid reason to use it. Read more. But if you don't add it, you will not be able to know caller's number.

HOW TO USE #

Get stream Phone Call State #

final _phoneCallStatePlugin = PhoneCallState.instance;
void subscriptionPhoneCallStateChange() async {
  _phoneCallStatePlugin.phoneStateChange.listen(
        (event) {
          switch (event.state) {
            case CallState.end:
            // TODO: Handle this case.
            case CallState.outgoing:
            // TODO: Handle this case.
            case CallState.outgoingAccept:
            // TODO: Handle this case.
            case CallState.incoming:
            // TODO: Handle this case.
            case CallState.call:
            // TODO: Handle this case.
            case CallState.none:
            // TODO: Handle this case.
            case CallState.hold:
            // TODO: Handle this case.
            case CallState.interruptAndHold:
            // TODO: Handle this case.
          }

      debugPrint(event.state.description);
    },
  );
}
copied to clipboard

Available Call States: #

The CallState enum represents various states during a phone call. Each state describes a specific point during the lifecycle of a call. Below are the possible call states:

  • CallState.end:
    The call has ended. This occurs when the call is either disconnected by the caller or the recipient.

  • CallState.outgoing:
    The call is in the process of being dialed (outgoing call). This state is active right after the user initiates the call but before the recipient has answered.

  • CallState.outgoingAccept:
    The outgoing call has been accepted by the recipient. This state indicates that the recipient has answered the call and the conversation is now live.

  • CallState.incoming:
    An incoming call is being received. The device is receiving the call, but the user has not answered it yet. This state is active when the phone is ringing.

  • CallState.call:
    The incoming call has been accepted. This state is triggered once the incoming call is answered by the user, and the conversation is ongoing.

  • CallState.hold:
    User press button Hold.

  • CallState.interruptAndHold:
    Interrupt the call and hold the current call to answer the new one.

  • CallState.none:
    The call state is unknown or undefined. This state is used when the call state cannot be determined or is not applicable.

These states help you track the progress of a phone call, allowing you to respond accordingly within your Flutter application.


class _MyAppState extends State<MyApp> {
  final _phoneCallStatePlugin = PhoneCallState.instance;
  String status = 'none';

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


  void subscriptionPhoneCallStateChange() async {
    _phoneCallStatePlugin.phoneStateChange.listen(
      (event) {
        debugPrint(
            "Phone Number: ${event.number}\nPhone Status:${event.state.name}");

        scheduleMicrotask((){
          setState(() {
            status = event.state.name;
          });
        });
        },
    );
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Text('Phone status: $status\n'),
        ),
      ),
    );
  }
}
copied to clipboard

Example App #

Example Video App
0
likes
0
points
94
downloads

Publisher

unverified uploader

Weekly Downloads

2024.05.31 - 2025.04.25

This Flutter plugin allows you to track and manage phone call states on Android and iOS devices.

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on flutter_phone_call_state