Search code examples
fluttercallkit

flutter_callkit_incoming. - error messages


The call kit upgrades brought new issues,

Name is not part of the event - no info in the package.

The getter 'name' isn't defined for the type 'CallEvent'. Try importing the library that defines 'name', correcting the name to the name of an existing getter, or defining a getter or field named 'name'

CallEvent is not defined

Undefined name 'CallEvent'. Try correcting the name to one that is defined, or defining the name.dartundefined_identifier Case expressions must be constant

  void setupNotificationAction() async {
    FlutterCallkitIncoming.onEvent.listen((event) async {
      switch (event!.name) {
        case CallEvent.ACTION_CALL_INCOMING:
          print('incoming call gaes');
          break;
        case CallEvent.ACTION_CALL_ACCEPT:
          print('body ' + event.body['extra']['roomName']);
          print('accept the data');
          TimeSlot selectedTimeslot = await TimeSlotService()
              .getTimeSlotById(event.body['extra']['selectedTimeslotId']);
          Get.toNamed('/video-call', arguments: [
            {
              'timeSlot': selectedTimeslot,
              'room': event.body['extra']['roomName'],
              'token': event.body['extra']['token']
            }
          ]);
          break;
        case CallEvent.ACTION_CALL_DECLINE:
          print('declien call gaes');
          break;
      }
    });
    // connecticube.ConnectycubeFlutterCallKit.instance.init(
    //   onCallAccepted: _onCallAccepted,
    //   onCallRejected: _onCallRejected,
    // );
  }

Solution

  • For anyone else coming to this question, here is a link to the flutter_callkit_incoming package (version 1.0.3+3 at the time of answering).

    The new version definitely seems broken. I would suggest using v 1.0.2+2 until it's fixed. Add this to your pubspec.yaml (do NOT include the ^)

    flutter_callkit_incoming: 1.0.2+2

    FlutterCallkitIncoming.onEvent.listen((CallEvent? event) {
          switch (event?.name) {
            case CallEvent.ACTION_CALL_INCOMING:
            // TODO: received an incoming call
              break;
            case CallEvent.ACTION_CALL_START:
            // TODO: started an outgoing call
            // TODO: show screen calling in Flutter
              break;
            case CallEvent.ACTION_CALL_ACCEPT:
            // TODO: accepted an incoming call
            // TODO: show screen calling in Flutter
              break;
            case CallEvent.ACTION_CALL_DECLINE:
            // TODO: declined an incoming call
              break;
            case CallEvent.ACTION_CALL_ENDED:
            // TODO: ended an incoming/outgoing call
              break;
            case CallEvent.ACTION_CALL_TIMEOUT:
            // TODO: missed an incoming call
              break;
            case CallEvent.ACTION_CALL_CALLBACK:
            // TODO: only Android - click action `Call back` from missed call notification
              break;
            case CallEvent.ACTION_CALL_TOGGLE_HOLD:
            // TODO: only iOS
              break;
            case CallEvent.ACTION_CALL_TOGGLE_MUTE:
            // TODO: only iOS
              break;
            case CallEvent.ACTION_CALL_TOGGLE_DMTF:
            // TODO: only iOS
              break;
            case CallEvent.ACTION_CALL_TOGGLE_GROUP:
            // TODO: only iOS
              break;
            case CallEvent.ACTION_CALL_TOGGLE_AUDIO_SESSION:
            // TODO: only iOS
              break;
            case CallEvent.ACTION_DID_UPDATE_DEVICE_PUSH_TOKEN_VOIP:
            // TODO: only iOS
              break;
          }
        });