Skip to content

Conversation

@AAkira
Copy link
Contributor

@AAkira AAkira commented Oct 24, 2025

This PR introduces type-safe refactoring across the codebase and reorganizes platform-specific parameters for better maintainability and developer
experience.

Key Changes

Type Safety Improvements:

  • Refactored CallEvent to use sealed classes with pattern matching for exhaustive event handling
  • Added toString() methods to all entity classes for better debugging
  • Changed activeCalls() return type from List<dynamic> to List<CallKitParams> for type safety
  • Updated example code to leverage type-safe APIs with pattern matching

Platform Parameter Reorganization:

  • Android: Consolidated Android-specific parameters (isCustomNotification, logoUrl, ringtonePath, backgroundColor, backgroundUrl,
    actionColor, textColor, etc.) into AndroidParams
  • iOS: Organized iOS-specific parameters (iconName, handleType, normalHandle, audioSessionMode, etc.) into IOSParams
  • Moved normalHandle from common parameters to iOS-specific (as it's only used on iOS)
  • Removed deprecated uuid field (now using id consistently)
  • Moved textAccept and textDecline to platform-specific parameters
  • Added headers parameter support
  • Reorganized parameter order in native code for better readability

Other Improvements:

  • Updated Dart SDK version
  • Fixed example application to use new type-safe APIs
  • Improved code organization and readability

Breaking Changes

  • CallEvent now uses sealed classes - event handling code needs to be updated to use pattern matching
  • activeCalls() now returns List<CallKitParams> instead of List<dynamic>
  • Some parameters have been moved to platform-specific classes (AndroidParams and IOSParams)

Migration Guide

Event Handling:

// Before                                                                                                                                         
switch (event!.event) {                                                                                                                           
  case Event.actionCallIncoming:                                                                                                                  
    // handle                                                                                                                                     
    break;                                                                                                                                        
}                                                                                                                                                 
                                                                                                                                                  
// After                                                                                                                                          
switch (event) {                                                                                                                                  
  case CallEventActionCallIncoming():                                                                                                             
    // handle                                                                                                                                     
    break;                                                                                                                                        
}                                                                                                                                                 

Active Calls:

// Before                                                                                                                                         
var calls = await FlutterCallkitIncoming.activeCalls();                                                                                           
if (calls is List && calls.isNotEmpty) {                                                                                                          
  var id = calls[0]['id'];                                                                                                                        
}                                                                                                                                                 
                                                                                                                                                  
// After                                                                                                                                          
var calls = await FlutterCallkitIncoming.activeCalls();                                                                                           
if (calls.isNotEmpty) {                                                                                                                           
  var id = calls[0].id;                                                                                                                           
}                                                                                                                                                 

Test Plan

Please carefully confirm all changes.

  • Verify incoming calls work on both Android and iOS
  • Verify outgoing calls work on both Android and iOS
  • Test call accept/decline actions
  • Test missed call notifications
  • Test custom notifications on Android
  • Verify iOS CallKit integration
  • Test all callback events with pattern matching
  • Verify example app works correctly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant