@@ -2,7 +2,6 @@ import 'dart:async';
22
33import 'package:flutter/material.dart' ;
44import 'package:web_callkit/web_callkit.dart' ;
5- import 'package:web_callkit/web_callkit_web.dart' ;
65import 'package:web_callkit_example/utils.dart' ;
76
87import '../../widgets/ck_card.dart' ;
@@ -38,6 +37,7 @@ class AdvancedScreen extends StatelessWidget {
3837}
3938
4039class _Content extends StatefulWidget {
40+ // ignore: unused_element
4141 const _Content ({super .key});
4242
4343 @override
@@ -71,17 +71,21 @@ class _ContentState extends State<_Content> {
7171 child: ElevatedButton (
7272 onPressed: _hasCall
7373 ? () async {
74- final call = await webCallkitPlugin.getCall (callId);
74+ final call = webCallkitPlugin.getCall (callId);
7575 if (call == null ) {
7676 return ;
7777 }
78- final cap =
79- call.capabilities.contains (e) ? call.capabilities.removeWith (e) : call.capabilities.addWith (e);
80- await webCallkitPlugin.updateCallCapabilities (callId, capabilities: cap);
78+ final cap = call.capabilities.contains (e)
79+ ? call.capabilities.removeWith (e)
80+ : call.capabilities.addWith (e);
81+ await webCallkitPlugin.updateCallCapabilities (callId,
82+ capabilities: cap);
8183 }
8284 : null ,
8385 style: ElevatedButton .styleFrom (
84- backgroundColor: _hasCall && _call! .capabilities.contains (e) ? Colors .green : Colors .transparent,
86+ backgroundColor: _hasCall && _call! .capabilities.contains (e)
87+ ? Colors .green
88+ : Colors .transparent,
8589 foregroundColor: Colors .white,
8690 ),
8791 child: Text (e.name.capitalize ()),
@@ -92,7 +96,9 @@ class _ContentState extends State<_Content> {
9296 return Padding (
9397 padding: const EdgeInsets .all (4.0 ),
9498 child: ElevatedButton (
95- style: ElevatedButton .styleFrom (backgroundColor: Colors .orangeAccent, foregroundColor: Colors .white),
99+ style: ElevatedButton .styleFrom (
100+ backgroundColor: Colors .orangeAccent,
101+ foregroundColor: Colors .white),
96102 onPressed: _hasCall && _call! .callType != e
97103 ? () async {
98104 await webCallkitPlugin.updateCallType (callId, callType: e);
@@ -106,10 +112,13 @@ class _ContentState extends State<_Content> {
106112 return Padding (
107113 padding: const EdgeInsets .all (4.0 ),
108114 child: ElevatedButton (
109- style: ElevatedButton .styleFrom (backgroundColor: Colors .deepPurpleAccent, foregroundColor: Colors .white),
115+ style: ElevatedButton .styleFrom (
116+ backgroundColor: Colors .deepPurpleAccent,
117+ foregroundColor: Colors .white),
110118 onPressed: _hasCall && _call! .state != e
111119 ? () async {
112- await webCallkitPlugin.updateCallStatus (callId, callStatus: e);
120+ await webCallkitPlugin.updateCallStatus (callId,
121+ callStatus: e);
113122 }
114123 : null ,
115124 child: Text (e.name.capitalize ()),
@@ -140,7 +149,6 @@ class _ContentState extends State<_Content> {
140149 },
141150 child: const Text ('Report Outgoing Call' ),
142151 ),
143-
144152 const SizedBox (width: 8 ),
145153 ElevatedButton (
146154 onPressed: () async {
@@ -156,7 +164,6 @@ class _ContentState extends State<_Content> {
156164 },
157165 child: const Text ('Report Ongoing Call' ),
158166 ),
159-
160167 const SizedBox (width: 8 ),
161168 ElevatedButton (
162169 onPressed: () async {
@@ -171,14 +178,15 @@ class _ContentState extends State<_Content> {
171178 },
172179 child: const Text ('Report Incoming Call' ),
173180 ),
174-
175181 const SizedBox (width: 8 ),
176182 ElevatedButton .icon (
177- style: ElevatedButton .styleFrom (backgroundColor: Colors .red, foregroundColor: Colors .white),
183+ style: ElevatedButton .styleFrom (
184+ backgroundColor: Colors .red, foregroundColor: Colors .white),
178185 icon: const Icon (Icons .call_end),
179186 onPressed: _hasCall
180187 ? () async {
181- await webCallkitPlugin.reportCallDisconnected (callId, response: DisconnectResponse .local);
188+ await webCallkitPlugin.reportCallDisconnected (callId,
189+ response: DisconnectResponse .local);
182190 }
183191 : null ,
184192 label: const Text ('Report Call Disconnected' ),
@@ -192,34 +200,46 @@ class _ContentState extends State<_Content> {
192200 mainAxisAlignment: MainAxisAlignment .center,
193201 children: [
194202 ElevatedButton (
195- style: ElevatedButton .styleFrom (backgroundColor: Colors .blue, foregroundColor: Colors .white),
196- onPressed:
197- _hasCall && ! _call! .isHolding && (_call! .hasCapabilityHold || _call! .hasCapabilitySupportsHold)
198- ? () async {
199- final call = await webCallkitPlugin.getCall (callId);
200- if (call == null ) {
201- return ;
202- }
203- final attr = call.attributes.addWith (CallAttributes .hold);
204- await webCallkitPlugin.updateCallAttributes (callId, attributes: attr);
205- }
206- : null ,
203+ style: ElevatedButton .styleFrom (
204+ backgroundColor: Colors .blue,
205+ foregroundColor: Colors .white),
206+ onPressed: _hasCall &&
207+ ! _call! .isHolding &&
208+ (_call! .hasCapabilityHold ||
209+ _call! .hasCapabilitySupportsHold)
210+ ? () async {
211+ final call = webCallkitPlugin.getCall (callId);
212+ if (call == null ) {
213+ return ;
214+ }
215+ final attr =
216+ call.attributes.addWith (CallAttributes .hold);
217+ await webCallkitPlugin.updateCallAttributes (callId,
218+ attributes: attr);
219+ }
220+ : null ,
207221 child: const Text ("Hold" ),
208222 ),
209223 const SizedBox (width: 8 ),
210224 ElevatedButton (
211- style: ElevatedButton .styleFrom (backgroundColor: Colors .blue, foregroundColor: Colors .white),
212- onPressed:
213- _hasCall && _call! .isHolding && (_call! .hasCapabilityHold || _call! .hasCapabilitySupportsHold)
214- ? () async {
215- final call = await webCallkitPlugin.getCall (callId);
216- if (call == null ) {
217- return ;
218- }
219- final attr = call.attributes.removeWith (CallAttributes .hold);
220- await webCallkitPlugin.updateCallAttributes (callId, attributes: attr);
221- }
222- : null ,
225+ style: ElevatedButton .styleFrom (
226+ backgroundColor: Colors .blue,
227+ foregroundColor: Colors .white),
228+ onPressed: _hasCall &&
229+ _call! .isHolding &&
230+ (_call! .hasCapabilityHold ||
231+ _call! .hasCapabilitySupportsHold)
232+ ? () async {
233+ final call = webCallkitPlugin.getCall (callId);
234+ if (call == null ) {
235+ return ;
236+ }
237+ final attr =
238+ call.attributes.removeWith (CallAttributes .hold);
239+ await webCallkitPlugin.updateCallAttributes (callId,
240+ attributes: attr);
241+ }
242+ : null ,
223243 child: const Text ("Resume" ),
224244 ),
225245 ],
@@ -232,32 +252,42 @@ class _ContentState extends State<_Content> {
232252 mainAxisAlignment: MainAxisAlignment .center,
233253 children: [
234254 ElevatedButton (
235- style: ElevatedButton .styleFrom (backgroundColor: Colors .purple, foregroundColor: Colors .white),
236- onPressed: _hasCall && ! _call! .isMuted && _call! .hasCapabilityMute
237- ? () async {
238- final call = await webCallkitPlugin.getCall (callId);
239- if (call == null ) {
240- return ;
241- }
242- final attr = call.attributes.addWith (CallAttributes .mute);
243- await webCallkitPlugin.updateCallAttributes (callId, attributes: attr);
244- }
245- : null ,
255+ style: ElevatedButton .styleFrom (
256+ backgroundColor: Colors .purple,
257+ foregroundColor: Colors .white),
258+ onPressed:
259+ _hasCall && ! _call! .isMuted && _call! .hasCapabilityMute
260+ ? () async {
261+ final call = webCallkitPlugin.getCall (callId);
262+ if (call == null ) {
263+ return ;
264+ }
265+ final attr =
266+ call.attributes.addWith (CallAttributes .mute);
267+ await webCallkitPlugin.updateCallAttributes (callId,
268+ attributes: attr);
269+ }
270+ : null ,
246271 child: const Text ("Mute" ),
247272 ),
248273 const SizedBox (width: 8 ),
249274 ElevatedButton (
250- style: ElevatedButton .styleFrom (backgroundColor: Colors .purple, foregroundColor: Colors .white),
251- onPressed: _hasCall && _call! .isMuted && _call! .hasCapabilityMute
252- ? () async {
253- final call = await webCallkitPlugin.getCall (callId);
254- if (call == null ) {
255- return ;
256- }
257- final attr = call.attributes.removeWith (CallAttributes .mute);
258- await webCallkitPlugin.updateCallAttributes (callId, attributes: attr);
259- }
260- : null ,
275+ style: ElevatedButton .styleFrom (
276+ backgroundColor: Colors .purple,
277+ foregroundColor: Colors .white),
278+ onPressed:
279+ _hasCall && _call! .isMuted && _call! .hasCapabilityMute
280+ ? () async {
281+ final call = webCallkitPlugin.getCall (callId);
282+ if (call == null ) {
283+ return ;
284+ }
285+ final attr =
286+ call.attributes.removeWith (CallAttributes .mute);
287+ await webCallkitPlugin.updateCallAttributes (callId,
288+ attributes: attr);
289+ }
290+ : null ,
261291 child: const Text ("Unmute" ),
262292 ),
263293 ],
@@ -308,7 +338,8 @@ class _ContentState extends State<_Content> {
308338 ElevatedButton (
309339 onPressed: _hasCall
310340 ? () async {
311- await webCallkitPlugin.updateCallData (callId, data: {"key" : "value" });
341+ await webCallkitPlugin
342+ .updateCallData (callId, data: {"key" : "value" });
312343 }
313344 : null ,
314345 child: const Text ("Set Data" ),
@@ -317,13 +348,15 @@ class _ContentState extends State<_Content> {
317348 ElevatedButton (
318349 onPressed: _hasCall
319350 ? () async {
320- final call = await webCallkitPlugin.getCall (callId);
351+ final call = webCallkitPlugin.getCall (callId);
321352 if (call == null ) {
322353 return ;
323354 }
324355 final data = call.data ?? {};
325- data.update ("key" , (value) => "value2" , ifAbsent: () => "value3" );
326- await webCallkitPlugin.updateCallData (callId, data: data);
356+ data.update ("key" , (value) => "value2" ,
357+ ifAbsent: () => "value3" );
358+ await webCallkitPlugin.updateCallData (callId,
359+ data: data);
327360 }
328361 : null ,
329362 child: const Text ("Update Data" ),
@@ -332,13 +365,14 @@ class _ContentState extends State<_Content> {
332365 ElevatedButton (
333366 onPressed: _hasCall
334367 ? () async {
335- final call = await webCallkitPlugin.getCall (callId);
368+ final call = webCallkitPlugin.getCall (callId);
336369 if (call == null ) {
337370 return ;
338371 }
339372 final data = call.data ?? {};
340373 data.remove ("key" );
341- await webCallkitPlugin.updateCallData (callId, data: data);
374+ await webCallkitPlugin.updateCallData (callId,
375+ data: data);
342376 }
343377 : null ,
344378 child: const Text ("Remove Data" ),
0 commit comments