@cometchat/skills 4.1.0 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/install.js +298 -41
- package/package.json +1 -1
- package/skills/cometchat/SKILL.md +146 -27
- package/skills/cometchat-a11y/SKILL.md +476 -0
- package/skills/cometchat-android-v5/SKILL.md +1 -1
- package/skills/cometchat-android-v5-calls/SKILL.md +413 -0
- package/skills/cometchat-android-v5-calls/references/README.md +53 -0
- package/skills/cometchat-android-v5-calls/references/add-calls-to-existing-chat.md +195 -0
- package/skills/cometchat-android-v5-calls/references/audio-controls.md +91 -0
- package/skills/cometchat-android-v5-calls/references/background-handling.md +168 -0
- package/skills/cometchat-android-v5-calls/references/call-layouts.md +123 -0
- package/skills/cometchat-android-v5-calls/references/call-logs.md +113 -0
- package/skills/cometchat-android-v5-calls/references/call-session.md +274 -0
- package/skills/cometchat-android-v5-calls/references/custom-ui.md +150 -0
- package/skills/cometchat-android-v5-calls/references/event-listeners.md +123 -0
- package/skills/cometchat-android-v5-calls/references/group-calls.md +205 -0
- package/skills/cometchat-android-v5-calls/references/idle-timeout.md +111 -0
- package/skills/cometchat-android-v5-calls/references/in-call-chat.md +134 -0
- package/skills/cometchat-android-v5-calls/references/join-session.md +120 -0
- package/skills/cometchat-android-v5-calls/references/migration-v4-to-v5.md +206 -0
- package/skills/cometchat-android-v5-calls/references/participant-management.md +110 -0
- package/skills/cometchat-android-v5-calls/references/picture-in-picture.md +106 -0
- package/skills/cometchat-android-v5-calls/references/raise-hand.md +242 -0
- package/skills/cometchat-android-v5-calls/references/recording.md +101 -0
- package/skills/cometchat-android-v5-calls/references/ringing-integration.md +152 -0
- package/skills/cometchat-android-v5-calls/references/screen-sharing.md +82 -0
- package/skills/cometchat-android-v5-calls/references/server-fcm-voip.md +215 -0
- package/skills/cometchat-android-v5-calls/references/session-settings.md +121 -0
- package/skills/cometchat-android-v5-calls/references/setup.md +137 -0
- package/skills/cometchat-android-v5-calls/references/share-invite.md +151 -0
- package/skills/cometchat-android-v5-calls/references/video-controls.md +87 -0
- package/skills/cometchat-android-v5-calls/references/voip-calling.md +526 -0
- package/skills/cometchat-android-v5-components/SKILL.md +1 -1
- package/skills/cometchat-android-v5-core/SKILL.md +1 -1
- package/skills/cometchat-android-v5-customization/SKILL.md +1 -1
- package/skills/cometchat-android-v5-extensions/SKILL.md +1 -1
- package/skills/cometchat-android-v5-features/SKILL.md +1 -1
- package/skills/cometchat-android-v5-placement/SKILL.md +1 -1
- package/skills/cometchat-android-v5-production/SKILL.md +1 -1
- package/skills/cometchat-android-v5-push/SKILL.md +1 -1
- package/skills/cometchat-android-v5-testing/SKILL.md +1 -1
- package/skills/cometchat-android-v5-theming/SKILL.md +1 -1
- package/skills/cometchat-android-v5-troubleshooting/SKILL.md +1 -1
- package/skills/cometchat-android-v6/SKILL.md +1 -1
- package/skills/cometchat-android-v6-builder-settings/SKILL.md +1 -1
- package/skills/cometchat-android-v6-calls/SKILL.md +375 -0
- package/skills/cometchat-android-v6-calls/references/add-calls-to-existing-chat.md +97 -0
- package/skills/cometchat-android-v6-calls/references/call-layouts.md +91 -0
- package/skills/cometchat-android-v6-calls/references/call-session.md +163 -0
- package/skills/cometchat-android-v6-calls/references/device-management.md +171 -0
- package/skills/cometchat-android-v6-calls/references/group-calls.md +191 -0
- package/skills/cometchat-android-v6-calls/references/idle-timeout.md +107 -0
- package/skills/cometchat-android-v6-calls/references/in-call-chat.md +136 -0
- package/skills/cometchat-android-v6-calls/references/raise-hand.md +186 -0
- package/skills/cometchat-android-v6-calls/references/ringing-integration.md +176 -0
- package/skills/cometchat-android-v6-calls/references/server-fcm-voip.md +127 -0
- package/skills/cometchat-android-v6-calls/references/share-invite.md +105 -0
- package/skills/cometchat-android-v6-compose-components/SKILL.md +2 -2
- package/skills/cometchat-android-v6-compose-customization/SKILL.md +1 -1
- package/skills/cometchat-android-v6-compose-placement/SKILL.md +1 -1
- package/skills/cometchat-android-v6-compose-theming/SKILL.md +1 -1
- package/skills/cometchat-android-v6-core/SKILL.md +1 -1
- package/skills/cometchat-android-v6-events/SKILL.md +1 -1
- package/skills/cometchat-android-v6-extensions/SKILL.md +1 -1
- package/skills/cometchat-android-v6-features/SKILL.md +1 -1
- package/skills/cometchat-android-v6-kotlin-components/SKILL.md +1 -1
- package/skills/cometchat-android-v6-kotlin-customization/SKILL.md +1 -1
- package/skills/cometchat-android-v6-kotlin-placement/SKILL.md +1 -1
- package/skills/cometchat-android-v6-kotlin-theming/SKILL.md +1 -1
- package/skills/cometchat-android-v6-migration/SKILL.md +398 -0
- package/skills/cometchat-android-v6-production/SKILL.md +1 -1
- package/skills/cometchat-android-v6-push/SKILL.md +1 -1
- package/skills/cometchat-android-v6-testing/SKILL.md +1 -1
- package/skills/cometchat-android-v6-troubleshooting/SKILL.md +1 -1
- package/skills/cometchat-angular-calls/SKILL.md +511 -0
- package/skills/cometchat-angular-calls/references/add-calls-to-existing-chat.md +95 -0
- package/skills/cometchat-angular-calls/references/call-layouts.md +106 -0
- package/skills/cometchat-angular-calls/references/call-session.md +167 -0
- package/skills/cometchat-angular-calls/references/custom-ui.md +231 -0
- package/skills/cometchat-angular-calls/references/device-management.md +135 -0
- package/skills/cometchat-angular-calls/references/group-calls.md +412 -0
- package/skills/cometchat-angular-calls/references/idle-timeout.md +145 -0
- package/skills/cometchat-angular-calls/references/in-call-chat.md +148 -0
- package/skills/cometchat-angular-calls/references/lazy-loading-pitfalls.md +205 -0
- package/skills/cometchat-angular-calls/references/migration-v4-to-v5.md +53 -0
- package/skills/cometchat-angular-calls/references/ngzone-and-async-callbacks.md +183 -0
- package/skills/cometchat-angular-calls/references/picture-in-picture.md +285 -0
- package/skills/cometchat-angular-calls/references/raise-hand.md +167 -0
- package/skills/cometchat-angular-calls/references/recording-screen-share.md +267 -0
- package/skills/cometchat-angular-calls/references/ringing-integration.md +131 -0
- package/skills/cometchat-angular-calls/references/server-web-push-vapid.md +100 -0
- package/skills/cometchat-angular-calls/references/share-invite.md +116 -0
- package/skills/cometchat-angular-components/SKILL.md +1 -1
- package/skills/cometchat-angular-core/SKILL.md +1 -1
- package/skills/cometchat-angular-customization/SKILL.md +1 -1
- package/skills/cometchat-angular-features/SKILL.md +1 -1
- package/skills/cometchat-angular-patterns/SKILL.md +1 -1
- package/skills/cometchat-angular-placement/SKILL.md +1 -1
- package/skills/cometchat-angular-production/SKILL.md +1 -1
- package/skills/cometchat-angular-push/SKILL.md +403 -0
- package/skills/cometchat-angular-testing/SKILL.md +333 -0
- package/skills/cometchat-angular-theming/SKILL.md +1 -1
- package/skills/cometchat-angular-troubleshooting/SKILL.md +1 -1
- package/skills/cometchat-astro-patterns/SKILL.md +1 -1
- package/skills/cometchat-calls/SKILL.md +358 -0
- package/skills/cometchat-calls/references/use-case-broadcast.md +194 -0
- package/skills/cometchat-calls/references/use-case-marketplace.md +158 -0
- package/skills/cometchat-calls/references/use-case-support.md +190 -0
- package/skills/cometchat-calls/references/use-case-team.md +169 -0
- package/skills/cometchat-calls/references/use-case-telehealth.md +154 -0
- package/skills/cometchat-components/SKILL.md +1 -1
- package/skills/cometchat-core/SKILL.md +1 -1
- package/skills/cometchat-customization/SKILL.md +2 -2
- package/skills/cometchat-features/SKILL.md +2 -2
- package/skills/cometchat-flutter-v5/SKILL.md +1 -1
- package/skills/cometchat-flutter-v5-calls/SKILL.md +325 -94
- package/skills/cometchat-flutter-v5-calls/references/add-calls-to-existing-chat.md +169 -0
- package/skills/cometchat-flutter-v5-calls/references/call-layouts.md +98 -0
- package/skills/cometchat-flutter-v5-calls/references/call-session.md +330 -0
- package/skills/cometchat-flutter-v5-calls/references/device-management.md +120 -0
- package/skills/cometchat-flutter-v5-calls/references/group-calls.md +187 -0
- package/skills/cometchat-flutter-v5-calls/references/idle-timeout.md +97 -0
- package/skills/cometchat-flutter-v5-calls/references/in-call-chat.md +132 -0
- package/skills/cometchat-flutter-v5-calls/references/migration-v4-to-v5.md +160 -0
- package/skills/cometchat-flutter-v5-calls/references/raise-hand.md +244 -0
- package/skills/cometchat-flutter-v5-calls/references/ringing-integration.md +193 -0
- package/skills/cometchat-flutter-v5-calls/references/server-push-bridge.md +101 -0
- package/skills/cometchat-flutter-v5-calls/references/share-invite.md +142 -0
- package/skills/cometchat-flutter-v5-conversations/SKILL.md +1 -1
- package/skills/cometchat-flutter-v5-core/SKILL.md +1 -1
- package/skills/cometchat-flutter-v5-customization/SKILL.md +1 -1
- package/skills/cometchat-flutter-v5-events/SKILL.md +1 -1
- package/skills/cometchat-flutter-v5-messages/SKILL.md +1 -1
- package/skills/cometchat-flutter-v5-production/SKILL.md +1 -1
- package/skills/cometchat-flutter-v5-push/SKILL.md +1 -1
- package/skills/cometchat-flutter-v5-testing/SKILL.md +390 -0
- package/skills/cometchat-flutter-v5-theming/SKILL.md +1 -1
- package/skills/cometchat-flutter-v5-troubleshooting/SKILL.md +1 -1
- package/skills/cometchat-flutter-v5-users-groups/SKILL.md +1 -1
- package/skills/cometchat-flutter-v6/SKILL.md +1 -1
- package/skills/cometchat-flutter-v6-calls/SKILL.md +308 -243
- package/skills/cometchat-flutter-v6-calls/references/add-calls-to-existing-chat.md +134 -0
- package/skills/cometchat-flutter-v6-calls/references/call-layouts.md +102 -0
- package/skills/cometchat-flutter-v6-calls/references/call-session.md +229 -0
- package/skills/cometchat-flutter-v6-calls/references/device-management.md +99 -0
- package/skills/cometchat-flutter-v6-calls/references/group-calls.md +190 -0
- package/skills/cometchat-flutter-v6-calls/references/idle-timeout.md +80 -0
- package/skills/cometchat-flutter-v6-calls/references/in-call-chat.md +122 -0
- package/skills/cometchat-flutter-v6-calls/references/raise-hand.md +268 -0
- package/skills/cometchat-flutter-v6-calls/references/ringing-integration.md +171 -0
- package/skills/cometchat-flutter-v6-calls/references/server-push-bridge.md +93 -0
- package/skills/cometchat-flutter-v6-calls/references/share-invite.md +102 -0
- package/skills/cometchat-flutter-v6-components/SKILL.md +1 -1
- package/skills/cometchat-flutter-v6-conversations/SKILL.md +1 -1
- package/skills/cometchat-flutter-v6-core/SKILL.md +1 -1
- package/skills/cometchat-flutter-v6-customization/SKILL.md +1 -1
- package/skills/cometchat-flutter-v6-events/SKILL.md +1 -1
- package/skills/cometchat-flutter-v6-features/SKILL.md +1 -1
- package/skills/cometchat-flutter-v6-messages/SKILL.md +1 -1
- package/skills/cometchat-flutter-v6-migration/SKILL.md +1 -1
- package/skills/cometchat-flutter-v6-placement/SKILL.md +1 -1
- package/skills/cometchat-flutter-v6-production/SKILL.md +1 -1
- package/skills/cometchat-flutter-v6-push/SKILL.md +452 -0
- package/skills/cometchat-flutter-v6-testing/SKILL.md +319 -0
- package/skills/cometchat-flutter-v6-theming/SKILL.md +1 -1
- package/skills/cometchat-flutter-v6-troubleshooting/SKILL.md +1 -1
- package/skills/cometchat-flutter-v6-users-groups/SKILL.md +1 -1
- package/skills/cometchat-i18n/SKILL.md +358 -0
- package/skills/cometchat-ios/SKILL.md +5 -5
- package/skills/cometchat-ios-calls/SKILL.md +409 -0
- package/skills/cometchat-ios-calls/references/add-calls-to-existing-chat.md +172 -0
- package/skills/cometchat-ios-calls/references/avaudiosession-routing.md +189 -0
- package/skills/cometchat-ios-calls/references/call-layouts.md +136 -0
- package/skills/cometchat-ios-calls/references/call-session.md +221 -0
- package/skills/cometchat-ios-calls/references/callkit-and-pushkit.md +353 -0
- package/skills/cometchat-ios-calls/references/custom-ui.md +322 -0
- package/skills/cometchat-ios-calls/references/device-management.md +171 -0
- package/skills/cometchat-ios-calls/references/group-calls.md +396 -0
- package/skills/cometchat-ios-calls/references/idle-timeout.md +185 -0
- package/skills/cometchat-ios-calls/references/in-call-chat.md +183 -0
- package/skills/cometchat-ios-calls/references/migration-v4-to-v5.md +138 -0
- package/skills/cometchat-ios-calls/references/picture-in-picture.md +246 -0
- package/skills/cometchat-ios-calls/references/raise-hand.md +239 -0
- package/skills/cometchat-ios-calls/references/recording-screen-share.md +339 -0
- package/skills/cometchat-ios-calls/references/ringing-integration.md +142 -0
- package/skills/cometchat-ios-calls/references/server-apns-pushkit.md +267 -0
- package/skills/cometchat-ios-calls/references/share-invite.md +152 -0
- package/skills/cometchat-ios-calls/references/swiftui-uikit-hosting.md +246 -0
- package/skills/cometchat-ios-calls/references/voip-cert-setup.md +166 -0
- package/skills/cometchat-ios-components/SKILL.md +1 -1
- package/skills/cometchat-ios-core/SKILL.md +1 -1
- package/skills/cometchat-ios-customization/SKILL.md +1 -1
- package/skills/cometchat-ios-features/SKILL.md +1 -1
- package/skills/cometchat-ios-placement/SKILL.md +1 -1
- package/skills/cometchat-ios-production/SKILL.md +1 -1
- package/skills/cometchat-ios-push/SKILL.md +1 -1
- package/skills/cometchat-ios-testing/SKILL.md +371 -0
- package/skills/cometchat-ios-theming/SKILL.md +1 -1
- package/skills/cometchat-ios-troubleshooting/SKILL.md +1 -1
- package/skills/cometchat-native-bare-patterns/SKILL.md +45 -3
- package/skills/cometchat-native-calls/SKILL.md +599 -0
- package/skills/cometchat-native-calls/references/add-calls-to-existing-chat.md +203 -0
- package/skills/cometchat-native-calls/references/call-layouts.md +124 -0
- package/skills/cometchat-native-calls/references/call-session.md +182 -0
- package/skills/cometchat-native-calls/references/custom-ui.md +250 -0
- package/skills/cometchat-native-calls/references/device-management.md +135 -0
- package/skills/cometchat-native-calls/references/expo-vs-bare.md +179 -0
- package/skills/cometchat-native-calls/references/group-calls.md +291 -0
- package/skills/cometchat-native-calls/references/idle-timeout.md +128 -0
- package/skills/cometchat-native-calls/references/in-call-chat.md +143 -0
- package/skills/cometchat-native-calls/references/migration-v4-to-v5.md +72 -0
- package/skills/cometchat-native-calls/references/picture-in-picture.md +276 -0
- package/skills/cometchat-native-calls/references/raise-hand.md +203 -0
- package/skills/cometchat-native-calls/references/recording-screen-share.md +290 -0
- package/skills/cometchat-native-calls/references/ringing-integration.md +118 -0
- package/skills/cometchat-native-calls/references/server-push-bridge.md +135 -0
- package/skills/cometchat-native-calls/references/server-push-payloads.md +193 -0
- package/skills/cometchat-native-calls/references/share-invite.md +144 -0
- package/skills/cometchat-native-calls/references/voip-push-end-to-end.md +317 -0
- package/skills/cometchat-native-components/SKILL.md +1 -1
- package/skills/cometchat-native-core/SKILL.md +1 -1
- package/skills/cometchat-native-customization/SKILL.md +1 -1
- package/skills/cometchat-native-expo-patterns/SKILL.md +18 -1
- package/skills/cometchat-native-features/SKILL.md +1 -1
- package/skills/cometchat-native-placement/SKILL.md +1 -1
- package/skills/cometchat-native-production/SKILL.md +1 -1
- package/skills/cometchat-native-push/SKILL.md +1 -1
- package/skills/cometchat-native-testing/SKILL.md +1 -1
- package/skills/cometchat-native-theming/SKILL.md +1 -1
- package/skills/cometchat-native-troubleshooting/SKILL.md +1 -1
- package/skills/cometchat-nextjs-patterns/SKILL.md +1 -1
- package/skills/cometchat-placement/SKILL.md +1 -1
- package/skills/cometchat-production/SKILL.md +1 -1
- package/skills/cometchat-react-calls/SKILL.md +539 -0
- package/skills/cometchat-react-calls/references/add-calls-to-existing-chat.md +145 -0
- package/skills/cometchat-react-calls/references/call-layouts.md +161 -0
- package/skills/cometchat-react-calls/references/call-session.md +235 -0
- package/skills/cometchat-react-calls/references/custom-ui.md +201 -0
- package/skills/cometchat-react-calls/references/device-management.md +206 -0
- package/skills/cometchat-react-calls/references/group-calls.md +262 -0
- package/skills/cometchat-react-calls/references/idle-timeout.md +175 -0
- package/skills/cometchat-react-calls/references/in-call-chat.md +212 -0
- package/skills/cometchat-react-calls/references/migration-v4-to-v5.md +172 -0
- package/skills/cometchat-react-calls/references/picture-in-picture.md +245 -0
- package/skills/cometchat-react-calls/references/raise-hand.md +238 -0
- package/skills/cometchat-react-calls/references/recording-screen-share.md +143 -0
- package/skills/cometchat-react-calls/references/ringing-integration.md +255 -0
- package/skills/cometchat-react-calls/references/server-web-push-vapid.md +241 -0
- package/skills/cometchat-react-calls/references/share-invite.md +176 -0
- package/skills/cometchat-react-calls/references/testing-calls-on-web.md +198 -0
- package/skills/cometchat-react-calls/references/voip-and-web-push.md +165 -0
- package/skills/cometchat-react-patterns/SKILL.md +1 -1
- package/skills/cometchat-react-push/SKILL.md +448 -0
- package/skills/cometchat-react-router-patterns/SKILL.md +1 -1
- package/skills/cometchat-react-testing/SKILL.md +404 -0
- package/skills/cometchat-theming/SKILL.md +3 -3
- package/skills/cometchat-troubleshooting/SKILL.md +2 -2
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
# Adding calls to an existing chat integration (Flutter V6 / Bloc)
|
|
2
|
+
|
|
3
|
+
V6 calls are **bundled** into `cometchat_chat_uikit: ^6.0.0-beta2` — no separate calls package. Toggle on by enabling calling in the UIKit settings.
|
|
4
|
+
|
|
5
|
+
**Read first:** `cometchat-flutter-v6-calls/SKILL.md` — V6 architecture (Bloc).
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Step 1 — Verify chat-uikit cohort
|
|
10
|
+
|
|
11
|
+
```yaml
|
|
12
|
+
# pubspec.yaml
|
|
13
|
+
dependencies:
|
|
14
|
+
cometchat_chat_uikit: ^6.0.0-beta2 # V6 — calls bundled
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
If you see `cometchat_calls_uikit` separately listed, you're on V5 cohort — see `cometchat-flutter-v5-calls/references/add-calls-to-existing-chat.md`.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Step 2 — Enable calling on UIKit init
|
|
22
|
+
|
|
23
|
+
```dart
|
|
24
|
+
import 'package:cometchat_chat_uikit/cometchat_chat_uikit.dart';
|
|
25
|
+
|
|
26
|
+
Future<void> main() async {
|
|
27
|
+
WidgetsFlutterBinding.ensureInitialized();
|
|
28
|
+
|
|
29
|
+
final settings = UIKitSettingsBuilder()
|
|
30
|
+
..setAppId(APP_ID)
|
|
31
|
+
..setRegion(REGION)
|
|
32
|
+
..enableCalling(); // NEW
|
|
33
|
+
|
|
34
|
+
await CometChatUIKit.init(uiKitSettings: settings.build());
|
|
35
|
+
runApp(const MyApp());
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
That's the entire migration. Calls init internally when chat init succeeds.
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## Step 3 — iOS + Android native config
|
|
44
|
+
|
|
45
|
+
Same as V5 (see V5 sister doc) — Info.plist + permissions + ConnectionService don't change between cohorts.
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Step 4 — Mount CometChatIncomingCall
|
|
50
|
+
|
|
51
|
+
```dart
|
|
52
|
+
class MyApp extends StatelessWidget {
|
|
53
|
+
@override
|
|
54
|
+
Widget build(BuildContext context) {
|
|
55
|
+
return MaterialApp(
|
|
56
|
+
home: Stack(
|
|
57
|
+
children: [
|
|
58
|
+
BlocProvider(
|
|
59
|
+
create: (_) => AuthBloc()..add(LoginRequested()),
|
|
60
|
+
child: const AppRoot(),
|
|
61
|
+
),
|
|
62
|
+
const CometChatIncomingCall(),
|
|
63
|
+
],
|
|
64
|
+
),
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## Step 5 — Bloc-wrapped login + push registration
|
|
73
|
+
|
|
74
|
+
```dart
|
|
75
|
+
class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
|
76
|
+
AuthBloc({required this.api}) : super(const AuthState.initial()) {
|
|
77
|
+
on<LoginRequested>(_onLogin);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
Future<void> _onLogin(LoginRequested event, Emitter<AuthState> emit) async {
|
|
81
|
+
try {
|
|
82
|
+
final user = await CometChatUIKit.login(uid: event.uid, authKey: AUTH_KEY);
|
|
83
|
+
// No separate CometChatCalls.login in V6 — bundled
|
|
84
|
+
emit(AuthState.authenticated(user));
|
|
85
|
+
|
|
86
|
+
// Register VoIP push tokens after login
|
|
87
|
+
await context.read<CallPushBloc>().add(RegisterTokens(uid: user.uid));
|
|
88
|
+
} catch (e) {
|
|
89
|
+
emit(AuthState.failed(e.toString()));
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
(See `cometchat-flutter-v6-calls/references/server-push-bridge.md` for the CallPushBloc pattern.)
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## Step 6 — Hangup teardown via Bloc
|
|
100
|
+
|
|
101
|
+
```dart
|
|
102
|
+
class CallBloc extends Bloc<CallEvent, CallState> {
|
|
103
|
+
CallBloc() : super(const CallState.idle()) {
|
|
104
|
+
on<EndCall>(_onEndCall);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
Future<void> _onEndCall(EndCall event, Emitter<CallState> emit) async {
|
|
108
|
+
CometChatCalls.leaveSession();
|
|
109
|
+
await CometChat.endCall(event.sessionId);
|
|
110
|
+
// V6's bundled flow: no additional FlutterCallkitIncoming step;
|
|
111
|
+
// the kit handles it
|
|
112
|
+
emit(const CallState.ended());
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
## Verification checklist
|
|
120
|
+
|
|
121
|
+
- [ ] `cometchat_chat_uikit: ^6.0.0-beta2` (or higher V6) in pubspec
|
|
122
|
+
- [ ] `..enableCalling()` chained in UIKitSettingsBuilder
|
|
123
|
+
- [ ] Native config (iOS + Android) same as V5
|
|
124
|
+
- [ ] `CometChatIncomingCall` sibling-overlay at root
|
|
125
|
+
- [ ] VoIP push registration via CallPushBloc post-login
|
|
126
|
+
- [ ] Run `cometchat verify --calls` — should pass
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## Pointers
|
|
131
|
+
|
|
132
|
+
- `cometchat-flutter-v5-calls/references/add-calls-to-existing-chat.md` — V5 sister (separate calls package)
|
|
133
|
+
- `cometchat-flutter-v6-calls/SKILL.md` — V6 Bloc patterns
|
|
134
|
+
- `cometchat-flutter-v6-calls/references/server-push-bridge.md`
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# Call layouts on Flutter V6 (Bloc)
|
|
2
|
+
|
|
3
|
+
Same SDK shape; Bloc-driven layout state.
|
|
4
|
+
|
|
5
|
+
**Canonical docs:** https://www.cometchat.com/docs/calls/flutter/call-layouts
|
|
6
|
+
**Read first:** `cometchat-flutter-v5-calls/references/call-layouts.md` — SegmentedButton pattern + SDK API.
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Cubit (single-state, no events overhead)
|
|
11
|
+
|
|
12
|
+
A layout switcher is a great fit for a Cubit since it has only one piece of state with simple updates.
|
|
13
|
+
|
|
14
|
+
```dart
|
|
15
|
+
class CallLayoutCubit extends Cubit<CallLayout> {
|
|
16
|
+
CallLayoutCubit() : super(CallLayout.tile);
|
|
17
|
+
|
|
18
|
+
void set(CallLayout next) {
|
|
19
|
+
CometChatCalls.setLayout(next);
|
|
20
|
+
emit(next);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
void onSDKChanged(CallLayout next) {
|
|
24
|
+
emit(next); // already changed by kit's switcher; just sync
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Hook the SDK event:
|
|
30
|
+
|
|
31
|
+
```dart
|
|
32
|
+
@override
|
|
33
|
+
void onCallLayoutChanged(CallLayout layout) {
|
|
34
|
+
context.read<CallLayoutCubit>().onSDKChanged(layout);
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## Switcher widget
|
|
41
|
+
|
|
42
|
+
```dart
|
|
43
|
+
class LayoutSwitcher extends StatelessWidget {
|
|
44
|
+
const LayoutSwitcher({super.key});
|
|
45
|
+
|
|
46
|
+
@override
|
|
47
|
+
Widget build(BuildContext context) {
|
|
48
|
+
return BlocBuilder<CallLayoutCubit, CallLayout>(
|
|
49
|
+
builder: (context, layout) => SegmentedButton<CallLayout>(
|
|
50
|
+
segments: const [
|
|
51
|
+
ButtonSegment(value: CallLayout.tile, label: Text('Tile')),
|
|
52
|
+
ButtonSegment(value: CallLayout.sidebar, label: Text('Sidebar')),
|
|
53
|
+
ButtonSegment(value: CallLayout.spotlight, label: Text('Spotlight')),
|
|
54
|
+
],
|
|
55
|
+
selected: {layout},
|
|
56
|
+
onSelectionChanged: (set) {
|
|
57
|
+
if (set.isNotEmpty) {
|
|
58
|
+
context.read<CallLayoutCubit>().set(set.first);
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
),
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## Provide the cubit at call start
|
|
70
|
+
|
|
71
|
+
```dart
|
|
72
|
+
BlocProvider<CallLayoutCubit>(
|
|
73
|
+
create: (_) => CallLayoutCubit(),
|
|
74
|
+
child: const CallScreen(),
|
|
75
|
+
);
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## Anti-patterns
|
|
81
|
+
|
|
82
|
+
V5 sister rules apply, plus V6-specific:
|
|
83
|
+
|
|
84
|
+
1. **Using a full Bloc when Cubit fits.** Layout switcher is one-state-update — Cubit avoids the events boilerplate.
|
|
85
|
+
2. **`BlocListener` for switcher rebuild.** Use `BlocBuilder` — switcher *is* a UI that depends on state, not a side-effect.
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## Verification checklist
|
|
90
|
+
|
|
91
|
+
- [ ] `CallLayoutCubit` provided above the call screen
|
|
92
|
+
- [ ] `BlocBuilder` wraps the switcher
|
|
93
|
+
- [ ] `onCallLayoutChanged` syncs the cubit
|
|
94
|
+
- [ ] Real-device smoke: switcher cycles all 3 on Android + iOS
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## Pointers
|
|
99
|
+
|
|
100
|
+
- `cometchat-flutter-v5-calls/references/call-layouts.md` — V5 sister (GetX)
|
|
101
|
+
- `cometchat-flutter-v6-calls` SKILL.md
|
|
102
|
+
- Canonical docs: https://www.cometchat.com/docs/calls/flutter/call-layouts
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
# Call session — joinSession with no ringing (Flutter V6 / Bloc)
|
|
2
|
+
|
|
3
|
+
Bloc-driven adaptation of the upstream sample. Same SDK underneath as V5 (`cometchat_calls_sdk`); the V6 kit (`cometchat_chat_uikit ^6.0.0`) is OPTIONAL for session-only flows.
|
|
4
|
+
|
|
5
|
+
**Read first:**
|
|
6
|
+
- `cometchat-flutter-v5-calls/references/call-session.md` — V5 sister, canonical SDK API surface (callback shape, `SessionSettingsBuilder`, `SessionStatusListeners`)
|
|
7
|
+
- `cometchat-react-calls/references/call-session.md` — full cross-platform architecture
|
|
8
|
+
|
|
9
|
+
**Source of truth:** `~/Downloads/calls-sdk/calls-sdk-flutter-5/sample-apps/cometchat-calls-sample-app-flutter/lib/screens/call_screen.dart` (the SDK version is the same; only the state-management primitive differs between v5 GetX and v6 Bloc).
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Hard rules
|
|
14
|
+
|
|
15
|
+
All V5 rules apply (callback API, `SessionSettingsBuilder`, `SessionStatusListeners` interface, `CometChatOngoingCallService.launch/abort`, `SizedBox.expand`, no Chat SDK for session-only). The V6-specific delta is:
|
|
16
|
+
|
|
17
|
+
1. **Cubit, not full Bloc.** Single 1-state-update flow — Cubit is the right primitive. Don't introduce events + reducer ceremony.
|
|
18
|
+
2. **`BlocConsumer` for auto-pop on idle transition** — combines side-effect (Navigator.pop on terminated) with builder (loading / error / active UI).
|
|
19
|
+
3. **Cubit holds the listener references**, not the widget. `close()` calls `removeSessionStatusListener` + `CometChatOngoingCallService.abort()`.
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Cubit
|
|
24
|
+
|
|
25
|
+
```dart
|
|
26
|
+
import 'package:bloc/bloc.dart';
|
|
27
|
+
import 'package:cometchat_calls_sdk/cometchat_calls_sdk.dart';
|
|
28
|
+
import 'package:equatable/equatable.dart';
|
|
29
|
+
import 'package:flutter/widgets.dart';
|
|
30
|
+
import 'package:permission_handler/permission_handler.dart';
|
|
31
|
+
|
|
32
|
+
enum CallSessionStatus { idle, requesting, joining, active, leaving, error }
|
|
33
|
+
|
|
34
|
+
class CallSessionState extends Equatable {
|
|
35
|
+
final CallSessionStatus status;
|
|
36
|
+
final Widget? videoWidget;
|
|
37
|
+
final String? error;
|
|
38
|
+
const CallSessionState({this.status = CallSessionStatus.idle, this.videoWidget, this.error});
|
|
39
|
+
|
|
40
|
+
CallSessionState copyWith({
|
|
41
|
+
CallSessionStatus? status,
|
|
42
|
+
Widget? videoWidget,
|
|
43
|
+
String? error,
|
|
44
|
+
}) =>
|
|
45
|
+
CallSessionState(
|
|
46
|
+
status: status ?? this.status,
|
|
47
|
+
videoWidget: videoWidget ?? this.videoWidget,
|
|
48
|
+
error: error ?? this.error,
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
@override
|
|
52
|
+
List<Object?> get props => [status, videoWidget, error];
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
class CallSessionCubit extends Cubit<CallSessionState> implements SessionStatusListeners {
|
|
56
|
+
CallSessionCubit() : super(const CallSessionState());
|
|
57
|
+
|
|
58
|
+
CallSession? _callSession;
|
|
59
|
+
|
|
60
|
+
Future<void> join(String sessionId) async {
|
|
61
|
+
if (state.status != CallSessionStatus.idle) return;
|
|
62
|
+
emit(state.copyWith(status: CallSessionStatus.requesting));
|
|
63
|
+
|
|
64
|
+
final cam = await Permission.camera.request();
|
|
65
|
+
final mic = await Permission.microphone.request();
|
|
66
|
+
if (!cam.isGranted || !mic.isGranted) {
|
|
67
|
+
emit(state.copyWith(status: CallSessionStatus.error, error: 'Permission denied'));
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
emit(state.copyWith(status: CallSessionStatus.joining));
|
|
72
|
+
|
|
73
|
+
final settings = (SessionSettingsBuilder()
|
|
74
|
+
.setTitle('CometChat Meeting')
|
|
75
|
+
.startVideoPaused(false)
|
|
76
|
+
.startAudioMuted(false))
|
|
77
|
+
.build();
|
|
78
|
+
|
|
79
|
+
CometChatCalls.joinSession(
|
|
80
|
+
sessionId: sessionId,
|
|
81
|
+
sessionSettings: settings,
|
|
82
|
+
onSuccess: (Widget? widget) {
|
|
83
|
+
_callSession = CallSession.getInstance();
|
|
84
|
+
_callSession?.addSessionStatusListener(this);
|
|
85
|
+
CometChatOngoingCallService.launch();
|
|
86
|
+
emit(state.copyWith(status: CallSessionStatus.active, videoWidget: widget));
|
|
87
|
+
},
|
|
88
|
+
onError: (CometChatCallsException error) {
|
|
89
|
+
emit(state.copyWith(status: CallSessionStatus.error, error: error.message ?? 'Failed'));
|
|
90
|
+
},
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
Future<void> leave() async {
|
|
95
|
+
if (state.status == CallSessionStatus.idle) return;
|
|
96
|
+
emit(state.copyWith(status: CallSessionStatus.leaving));
|
|
97
|
+
try {
|
|
98
|
+
await _callSession?.leaveSession();
|
|
99
|
+
} catch (_) {
|
|
100
|
+
// best-effort
|
|
101
|
+
}
|
|
102
|
+
await CometChatOngoingCallService.abort();
|
|
103
|
+
emit(const CallSessionState()); // back to idle
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// --- SessionStatusListeners ---
|
|
107
|
+
@override
|
|
108
|
+
void onSessionJoined() {
|
|
109
|
+
CometChatOngoingCallService.launch();
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// All termination events funnel through ONE guarded _handleTermination().
|
|
113
|
+
// The v5 Calls SDK fires onSessionLeft + onConnectionClosed in sequence on
|
|
114
|
+
// every hangup. Without the guard, abort() + emit() fire 3 times (wasteful
|
|
115
|
+
// and races with cubit close on rapid leave/rejoin).
|
|
116
|
+
bool _isTerminating = false;
|
|
117
|
+
void _handleTermination() {
|
|
118
|
+
if (_isTerminating) return;
|
|
119
|
+
_isTerminating = true;
|
|
120
|
+
CometChatOngoingCallService.abort();
|
|
121
|
+
emit(const CallSessionState());
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
@override
|
|
125
|
+
void onSessionLeft() => _handleTermination();
|
|
126
|
+
|
|
127
|
+
@override
|
|
128
|
+
void onConnectionClosed() => _handleTermination();
|
|
129
|
+
|
|
130
|
+
@override
|
|
131
|
+
void onSessionTimedOut() => _handleTermination();
|
|
132
|
+
|
|
133
|
+
@override
|
|
134
|
+
void onConnectionLost() {}
|
|
135
|
+
@override
|
|
136
|
+
void onConnectionRestored() {}
|
|
137
|
+
|
|
138
|
+
@override
|
|
139
|
+
Future<void> close() async {
|
|
140
|
+
_callSession?.removeSessionStatusListener(this);
|
|
141
|
+
if (state.status != CallSessionStatus.idle) {
|
|
142
|
+
await CometChatOngoingCallService.abort();
|
|
143
|
+
try {
|
|
144
|
+
await _callSession?.leaveSession();
|
|
145
|
+
} catch (_) {}
|
|
146
|
+
}
|
|
147
|
+
return super.close();
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
## Call room widget
|
|
155
|
+
|
|
156
|
+
```dart
|
|
157
|
+
class CallRoom extends StatelessWidget {
|
|
158
|
+
final String sessionId;
|
|
159
|
+
const CallRoom({super.key, required this.sessionId});
|
|
160
|
+
|
|
161
|
+
@override
|
|
162
|
+
Widget build(BuildContext context) {
|
|
163
|
+
return BlocProvider<CallSessionCubit>(
|
|
164
|
+
create: (_) => CallSessionCubit()..join(sessionId),
|
|
165
|
+
child: BlocConsumer<CallSessionCubit, CallSessionState>(
|
|
166
|
+
listenWhen: (prev, curr) =>
|
|
167
|
+
prev.status != CallSessionStatus.idle && curr.status == CallSessionStatus.idle,
|
|
168
|
+
listener: (context, state) => Navigator.of(context).pop(),
|
|
169
|
+
builder: (context, state) {
|
|
170
|
+
if (state.status == CallSessionStatus.error) {
|
|
171
|
+
return Scaffold(
|
|
172
|
+
backgroundColor: Colors.black,
|
|
173
|
+
body: Center(child: Text('Error: ${state.error}', style: const TextStyle(color: Colors.white))),
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
if (state.status != CallSessionStatus.active || state.videoWidget == null) {
|
|
177
|
+
return const Scaffold(
|
|
178
|
+
backgroundColor: Colors.black,
|
|
179
|
+
body: Center(child: CircularProgressIndicator(color: Colors.white)),
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
return Scaffold(
|
|
183
|
+
backgroundColor: Colors.black,
|
|
184
|
+
body: SizedBox.expand(child: state.videoWidget),
|
|
185
|
+
);
|
|
186
|
+
},
|
|
187
|
+
),
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
---
|
|
194
|
+
|
|
195
|
+
## Anti-patterns
|
|
196
|
+
|
|
197
|
+
V5 sister rules apply, plus V6-specific:
|
|
198
|
+
|
|
199
|
+
1. **Storing the returned widget in the cubit's `_controller` field** as if it were a controller. The `Widget?` IS what you render — there is no controller layer in the v5 Calls SDK.
|
|
200
|
+
2. **Full Bloc with events for a 1-state-update flow.** Cubit fits cleanly.
|
|
201
|
+
3. **`BlocBuilder` instead of `BlocConsumer`.** Need both side-effect (auto-pop) and builder (loading/error UI).
|
|
202
|
+
4. **Forgetting `..join(sessionId)` cascade.** Cubit created but never starts joining.
|
|
203
|
+
5. **Forgetting to call `CometChatOngoingCallService.abort()` in `close()`.** Service notification persists after route pops.
|
|
204
|
+
6. **`CometChatOngoingCallController` / `CometChatOngoingCallView`.** These do not exist in the v5 Calls SDK API. Use the `Widget?` returned by `onSuccess` directly.
|
|
205
|
+
|
|
206
|
+
---
|
|
207
|
+
|
|
208
|
+
## Verification checklist
|
|
209
|
+
|
|
210
|
+
- [ ] Cubit implements `SessionStatusListeners` and registers itself in `onSuccess`
|
|
211
|
+
- [ ] `joinSession` called with `sessionId:`, `sessionSettings:`, `onSuccess:`, `onError:`
|
|
212
|
+
- [ ] Settings built via `SessionSettingsBuilder()`, not `CallSettings`
|
|
213
|
+
- [ ] `BlocProvider` creates cubit and triggers `..join(sessionId)`
|
|
214
|
+
- [ ] `BlocConsumer.listener` pops route on idle transition
|
|
215
|
+
- [ ] Loading / error UI for non-active states
|
|
216
|
+
- [ ] Widget rendered via `SizedBox.expand(child: state.videoWidget)`
|
|
217
|
+
- [ ] `close()` removes listener + aborts ongoing-call service + best-effort leaves
|
|
218
|
+
- [ ] **Standalone session-only:** no `cometchat_chat_sdk` dependency — Calls SDK alone
|
|
219
|
+
- [ ] Real-device smoke: same as V5 sister
|
|
220
|
+
|
|
221
|
+
---
|
|
222
|
+
|
|
223
|
+
## Pointers
|
|
224
|
+
|
|
225
|
+
- `cometchat-flutter-v5-calls/references/call-session.md` — V5 sister + canonical SDK API
|
|
226
|
+
- `cometchat-flutter-v6-calls/SKILL.md` — V6 Bloc patterns
|
|
227
|
+
- `cometchat-flutter-v6-calls/references/share-invite.md` — deep-link config
|
|
228
|
+
- Upstream sample — `~/Downloads/calls-sdk/calls-sdk-flutter-5/sample-apps/cometchat-calls-sample-app-flutter/lib/screens/call_screen.dart` (SDK is the same)
|
|
229
|
+
- Canonical docs: https://www.cometchat.com/docs/calls/flutter/join-session
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# Device management on Flutter V6 (Bloc)
|
|
2
|
+
|
|
3
|
+
Same SDK API as V5; Bloc-based state.
|
|
4
|
+
|
|
5
|
+
**Canonical docs:** https://www.cometchat.com/docs/calls/flutter/device-management
|
|
6
|
+
**Read first:** `cometchat-flutter-v5-calls/references/device-management.md` — SDK shape + flutter_callkit_incoming integration.
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## SDK API
|
|
11
|
+
|
|
12
|
+
Same as V5. `CometChatCalls.switchCamera()` and `CometChatCalls.setSpeakerEnabled(bool)`.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Bloc-driven device state
|
|
17
|
+
|
|
18
|
+
```dart
|
|
19
|
+
class DeviceState extends Equatable {
|
|
20
|
+
final bool speakerOn;
|
|
21
|
+
final bool cameraIsBack;
|
|
22
|
+
const DeviceState({this.speakerOn = false, this.cameraIsBack = false});
|
|
23
|
+
DeviceState copyWith({bool? speakerOn, bool? cameraIsBack}) =>
|
|
24
|
+
DeviceState(
|
|
25
|
+
speakerOn: speakerOn ?? this.speakerOn,
|
|
26
|
+
cameraIsBack: cameraIsBack ?? this.cameraIsBack,
|
|
27
|
+
);
|
|
28
|
+
@override List<Object> get props => [speakerOn, cameraIsBack];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
abstract class DeviceEvent {}
|
|
32
|
+
class ToggleSpeaker extends DeviceEvent {}
|
|
33
|
+
class FlipCamera extends DeviceEvent {}
|
|
34
|
+
|
|
35
|
+
class DeviceBloc extends Bloc<DeviceEvent, DeviceState> {
|
|
36
|
+
DeviceBloc() : super(const DeviceState()) {
|
|
37
|
+
on<ToggleSpeaker>((event, emit) {
|
|
38
|
+
final next = !state.speakerOn;
|
|
39
|
+
CometChatCalls.setSpeakerEnabled(next);
|
|
40
|
+
emit(state.copyWith(speakerOn: next));
|
|
41
|
+
});
|
|
42
|
+
on<FlipCamera>((event, emit) {
|
|
43
|
+
CometChatCalls.switchCamera();
|
|
44
|
+
emit(state.copyWith(cameraIsBack: !state.cameraIsBack));
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## Toggle widgets
|
|
53
|
+
|
|
54
|
+
```dart
|
|
55
|
+
class SpeakerToggle extends StatelessWidget {
|
|
56
|
+
const SpeakerToggle({super.key});
|
|
57
|
+
|
|
58
|
+
@override
|
|
59
|
+
Widget build(BuildContext context) {
|
|
60
|
+
return BlocBuilder<DeviceBloc, DeviceState>(
|
|
61
|
+
buildWhen: (prev, curr) => prev.speakerOn != curr.speakerOn,
|
|
62
|
+
builder: (context, state) => IconButton(
|
|
63
|
+
icon: Icon(state.speakerOn ? Icons.volume_up : Icons.hearing),
|
|
64
|
+
onPressed: () => context.read<DeviceBloc>().add(ToggleSpeaker()),
|
|
65
|
+
tooltip: state.speakerOn ? 'Switch to earpiece' : 'Switch to speaker',
|
|
66
|
+
),
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
`buildWhen` prevents re-rendering on unrelated state changes — important during a video call where rebuild thrash hurts performance.
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## Anti-patterns
|
|
77
|
+
|
|
78
|
+
Same as V5; plus V6-specific:
|
|
79
|
+
|
|
80
|
+
1. **`buildWhen` omitted.** Every state emit re-renders every BlocBuilder.
|
|
81
|
+
2. **Calling SDK methods inside Bloc handlers without try/catch.** Throwing inside the handler crashes the bloc.
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## Verification checklist
|
|
86
|
+
|
|
87
|
+
- [ ] DeviceBloc with `ToggleSpeaker` + `FlipCamera` events
|
|
88
|
+
- [ ] BlocBuilder uses `buildWhen` for narrow rebuilds
|
|
89
|
+
- [ ] State is `Equatable` with proper `props`
|
|
90
|
+
- [ ] Real-device smoke: speaker toggle, camera flip both work
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## Pointers
|
|
95
|
+
|
|
96
|
+
- `cometchat-flutter-v5-calls/references/device-management.md` — V5 sister
|
|
97
|
+
- `cometchat-flutter-v6-calls` SKILL.md
|
|
98
|
+
- `cometchat-flutter-v6-calls/references/raise-hand.md` — Bloc pattern sibling
|
|
99
|
+
- Canonical docs: https://www.cometchat.com/docs/calls/flutter/device-management
|