call_mode 0.1.1 copy "call_mode: ^0.1.1" to clipboard
call_mode: ^0.1.1 copied to clipboard

A handy plugin for retrieving and observing a current call mode

call_mode #

A plugin for getting and listening to a current call mode

Basic information #

There are currently implemented only following call modes:

inProgress ringing none
A call is currently active Incoming call ringing No active or ringing calls

Getting Started #

  • Add the plugin to your dependencies in pubspec.yaml

    dependencies:
        call_mode: ^0.1.0
    
  • Run the following command to get the package:

    flutter pub get
    
  • Import plugin to your dart file

    import 'package:call_mode/call_mode.dart';
    

Usage #

Getting current call mode #

You can get current call mode using CallModePlugin.instance.getCallMode() method.

Listening to call mode changes #

There are 2 ways to listen to call mode changes

  • Using CallModePlugin

    1. Add listener

      void someFunction() {
          CallModePlugin.instance.addListener(_callModeListener);
      }
             
      void _callModeListener(CallMode mode) {
          // TODO: your logic
      }
      
    2. Remove listener when you're done

      void dispose() {
          CallModePlugin.instance.removeListener(_callModeListener);
      }
      
  • Using CallModeListener or CallModeBuilder widgets

    • CallModeListener

      void _callModeListener(BuildContext context, CallMode mode) {
          // TODO: your logic
      }
            
      @override
      Widget build() {
          return CallModeListener(
              listener: _callModeListener,
              child: YourWidget(),
          );
      }
      
    • CallModeBuilder

      @override
      Widget build() {
          return CallModeBuilder(
              builder: (context, callMode) {
                  // TODO: your widgets
              },
          );
      }
      

Additional methods #

You can configure how often will an underlying system be checking for a call state.

Use CallModePlugin.instance.setListenerInterval(Duration duration) method.

!!! WARNING !!!

This method will affect ALL listeners in your app, including ones that are used inside CallModeBuilder's and CallModeListener's. It is because there is only one state watcher on platform side.

Platform implementations #

Android iOS
inProgress AudioManager.MODE_IN_CALL or AudioManager.MODE_IN_COMMUNICATION Any CXCall has hasEnded == false and hasConnected == true
ringing AudioManager.MODE_RINGTONE Any CXCall has hasEnded == false and hasConnected == false
none Any other AudioManager mode No CXCall's or all CXCall's have hasEnded == true
2
likes
150
points
26
downloads

Publisher

unverified uploader

Weekly Downloads

A handy plugin for retrieving and observing a current call mode

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on call_mode