How mindinventory/flutter_web_rtc_with_call_kit works
1. This is a Flutter mobile app for peer-to-peer audio/video calling, with native call UX on iOS via CallKit and Android/iOS platform setup for the Flutter runtime. The app is not a backend service; most application logic lives in the Flutter layer, with Firebase used as the cloud dependency for auth, signaling, and push notifications.
2. The architecture is split into three main planes:
- UI/presentation in lib/features/presentation/pages
- state management in lib/features/presentation/bloc
- shared infrastructure/utilities in lib/core and dependency wiring in lib/di
Native platform shells sit in android/ and ios/ to enable WebRTC, push, and call UI integrations.
3. Authentication is a distinct subsystem. The pages authentication_page.dart, login_page.dart, and sign_up_page.dart are backed by auth_bloc, which likely coordinates Firebase auth and user session state. After sign-in, the user is routed to home_page.dart, which acts as the app’s main control surface for initiating or receiving calls.
4. The calling subsystem is centered on WebRTC signaling plus media session handling. signaling_bloc indicates the app separates call/session events from general authentication. The app pages audio_call_page.dart and video_call_page.dart represent the in-call UI, while signaling logic likely exchanges SDP/ICE information through Firebase rather than a bespoke server.
5. Firebase is the main cloud boundary in this repo. The presence of firebase_core, cloud_firestore, firebase_messaging, firebase_options.dart, and firebase.json indicates the app depends on Firebase for:
- app bootstrap/configuration
- persistent user/call metadata
- signaling message exchange or call state storage
- push notifications for incoming calls
6. Incoming call handling is split between cloud messaging and native call presentation. lib/core/utils/fcm_helper.dart and lib/core/utils/callkit_helper.dart suggest FCM wakes or notifies the device, then CallKit presents the system-level incoming-call UI. The user’s accept/decline action then flows back into Flutter to continue or terminate the WebRTC session.
7. The data model layer is lightweight and generated from JSON serializable models. user.dart and notification_payload.dart with their .g.dart companions imply the app serializes Firestore/notification data into strongly typed Dart objects. This layer is the boundary between cloud payloads and BLoC/UI logic.
8. lib/core/utils contains cross-cutting infrastructure rather than feature logic. It includes navigation, shared preferences, general helpers, and platform/service wrappers. shared_prefs.dart plus shared_prefs_constants.dart indicate local persistence for session flags or lightweight app settings, while app_navigator.dart centralizes route transitions.
9. lib/core/widgets is a shared UI component library used across the feature pages. Components like custom buttons, text fields, image loading, app bars, and loading indicators keep the feature screens thin and consistent, which matters when diagramming the UI layer as composed of reusable primitives rather than duplicated page-specific widgets.
10. Dependency injection is explicit in lib/di/injector.dart. That file is the composition root for service and bloc wiring, so the app’s runtime dependencies are assembled centrally before UI pages consume them. This is important for the architecture diagram because it separates construction of services from their use in pages/blocs.
11. Platform code is minimal but necessary. Android uses a standard Flutter host with MainActivity.kt and Gradle configuration, while iOS includes AppDelegate.swift, a bridged header, CocoaPods setup, and Xcode workspace/project files. The native layer mainly exists to enable Flutter embedding, permissions, push notifications, and the CallKit integration required by the calling flow.
12. The repo is dependency-heavy on mobile communication libraries: flutter_webrtc for media transport and peer connection, flutter_callkit_incoming for system incoming-call presentation, and Firebase SDKs for cloud services. These libraries define the main external boundaries in the architecture more than any custom server code does.
13. The expected runtime flow is: app starts -> Firebase initializes -> auth state determines entry point -> user reaches home -> user initiates or receives a call -> signaling data is exchanged through Firebase -> WebRTC establishes media transport -> in-call pages render the session -> ending the call tears down both the peer connection and any active native call UI.
14. In diagram terms, the most important boundaries are:
- Flutter UI versus BLoC/state management
- BLoC versus Firebase/WebRTC service utilities
- Flutter runtime versus native Android/iOS call/notification hooks
- local persistence versus cloud-backed auth/signaling
This repo is best understood as a client application orchestrating real-time media and push-driven call setup, not as a server-centric system.
Main entry points: injector.dart Injector · signaling_bloc.dart Signaling BLoC · custom_appbar.dart Shared widgets · auth_bloc.dart Auth BLoC
Components 25
Presentation
Flutter pages and BLoC state flow
- Auth BLoC · Session and authentication state management
lib/features/presentation/bloc/auth_bloc/auth_bloc.dart - Signaling BLoC · Call session and signaling state management
lib/features/presentation/bloc/signaling_bloc/signaling_bloc.dart - Auth gate · Entry screen that routes into auth flow
lib/features/presentation/pages/authentication_page.dart - Login · User sign-in screen
lib/features/presentation/pages/login_page.dart - Sign up · Account creation screen
lib/features/presentation/pages/sign_up_page.dart - Home · Main control surface for calls
lib/features/presentation/pages/home_page.dart - Audio call · In-call audio UI
lib/features/presentation/pages/audio_call_page.dart - Video call · In-call video UI
lib/features/presentation/pages/video_call_page.dart
Core
Shared utilities, widgets, and dependency wiring
- App entry · Initializes the app runtime and wiring
lib/main.dart - Firebase opts · Generated Firebase initialization options
lib/firebase_options.dart - Injector · Central dependency wiring for blocs and services
lib/di/injector.dart - Navigator · Centralized route transitions and page navigation
lib/core/utils/app_navigator.dart - Prefs · Wrapper for lightweight persisted app state
lib/core/utils/shared_prefs.dart - FCM helper · Device push and incoming-call wakeup handling
lib/core/utils/fcm_helper.dart - CallKit helper · System incoming-call presentation bridge
lib/core/utils/callkit_helper.dart - Shared widgets · Reusable buttons, fields, loaders, and app bars
lib/core/widgets/custom_appbar.dart
Data
Serializable models and cloud payloads
- User model · Typed user/session payload boundary
lib/features/data/model/user.dart - Notif payload · Push notification/call payload boundary
lib/features/data/model/notification_payload.dart
Native
Android and iOS host shells
- Android shell · Flutter Android embedding and Gradle setup
android/app/src/main/kotlin/com/example/flutter_web_rtc_with_call_kit/MainActivity.kt - iOS shell · Flutter iOS embedding and CallKit-capable host
ios/Runner/AppDelegate.swift
External
Cloud, media, and OS integrations
- Firebase · Auth, Firestore, messaging, and app config backplane
- WebRTC · Peer connection and real-time audio/video transport
- CallKit · Native incoming-call presentation on iOS
- FCM · Cloud push notifications for incoming calls
- Local storage · On-device app preferences and session flags
Connections 35
- App entry → Firebase opts: configures · Bootstraps Firebase before the app runs
- App entry → Injector: builds · Creates the dependency graph
- App entry → Android shell: runs on · Uses the Android host runtime
- App entry → iOS shell: runs on · Uses the iOS host runtime
- Injector → Auth BLoC: wires · Registers authentication state management
- Injector → Signaling BLoC: wires · Registers call signaling state management
- Injector → Navigator: injects · Provides centralized navigation services
- Injector → Prefs: injects · Provides local persistence access
- Injector → FCM helper: injects · Provides push notification helper
- Injector → CallKit helper: injects · Provides native call UI bridge
- Auth gate → Auth BLoC: uses · Entry flow delegates to auth state
- Login → Auth BLoC: uses · Login form dispatches auth events
- Sign up → Auth BLoC: uses · Sign-up form dispatches auth events
- Home → Signaling BLoC: uses · Home screen starts and receives calls
- Home → Navigator: routes · Moves between auth, home, and call screens
- Audio call → Signaling BLoC: uses · Reflects active audio session state
- Video call → Signaling BLoC: uses · Reflects active video session state
- Auth BLoC → Firebase: authenticates · Relies on Firebase-backed user session data
- Auth BLoC → User model: maps · Converts cloud user data into typed state
- Signaling BLoC → Firebase: signals via · Uses Firebase as call signaling backplane
- Signaling BLoC → WebRTC: establishes · Coordinates peer connection lifecycle
- Signaling BLoC → Notif payload: maps · Converts push/call metadata into typed state
- FCM helper → FCM: listens to · Receives incoming call notifications
- CallKit helper → CallKit: presents · Shows system-level call UI
- FCM helper → Notif payload: decodes · Parses push payloads into app state
- Prefs → Local storage: reads/writes · Persists lightweight client settings
- Android shell → FCM: enables · Hosts Android push and runtime integration
- iOS shell → FCM: enables · Hosts iOS push integration
- iOS shell → CallKit: enables · Supports native incoming-call presentation
- Shared widgets → Auth gate: used by · Supports auth screens
- Shared widgets → Login: used by · Supports login screens
- Shared widgets → Sign up: used by · Supports sign-up screens
- Shared widgets → Home: used by · Supports main control surface
- Shared widgets → Audio call: used by · Supports call UI
- Shared widgets → Video call: used by · Supports call UI