@@ -6,63 +6,6 @@ import 'package:flutter/material.dart';
66
77import '../../stream_video_flutter.dart' ;
88
9- /// Builder used to create a custom incoming call widget.
10- ///
11- /// Replaced by the simplified [CallWidgetBuilder] .
12- @Deprecated ('Use CallWidgetBuilder instead.' )
13- typedef IncomingCallBuilder =
14- Widget Function (
15- BuildContext context,
16- Call call,
17- CallState callState,
18- );
19-
20- /// Builder used to create a custom outgoing call widget.
21- ///
22- /// Replaced by the simplified [CallWidgetBuilder] .
23- @Deprecated ('Use CallWidgetBuilder instead.' )
24- typedef OutgoingCallBuilder =
25- Widget Function (
26- BuildContext context,
27- Call call,
28- CallState callState,
29- );
30-
31- /// Builder used to create a custom call content widget.
32- ///
33- /// Replaced by the simplified [CallWidgetBuilder] .
34- @Deprecated ('Use CallWidgetBuilder instead.' )
35- typedef CallContentBuilder =
36- Widget Function (
37- BuildContext context,
38- Call call,
39- CallState callState,
40- );
41-
42- /// Builder used to create a custom widget for participants avatars.
43- ///
44- /// Replaced by the simplified [CallWidgetBuilder] .
45- @Deprecated ('Use CallWidgetBuilder instead.' )
46- typedef ParticipantsAvatarBuilder =
47- Widget Function (
48- BuildContext context,
49- Call call,
50- CallState callState,
51- List <UserInfo > participants,
52- );
53-
54- /// Builder used to create a custom widget for participants display names.
55- ///
56- /// Replaced by the simplified [CallWidgetBuilder] .
57- @Deprecated ('Use CallWidgetBuilder instead.' )
58- typedef ParticipantsDisplayNameBuilder =
59- Widget Function (
60- BuildContext context,
61- Call call,
62- CallState callState,
63- List <UserInfo > participants,
64- );
65-
669/// Represents different call content based on the call state.
6710class StreamCallContainer extends StatefulWidget {
6811 /// Creates a new instance of [StreamCallContainer] .
@@ -76,14 +19,8 @@ class StreamCallContainer extends StatefulWidget {
7619 this .onDeclineCallTap,
7720 this .onCancelCallTap,
7821 this .onCallDisconnected,
79- @Deprecated ('Use [incomingCallWidgetBuilder] instead.' )
80- this .incomingCallBuilder,
8122 this .incomingCallWidgetBuilder,
82- @Deprecated ('Use [outgoingCallWidgetBuilder] instead.' )
83- this .outgoingCallBuilder,
8423 this .outgoingCallWidgetBuilder,
85- @Deprecated ('Use [callContentWidgetBuilder] instead.' )
86- this .callContentBuilder,
8724 this .callContentWidgetBuilder,
8825 this .pictureInPictureConfiguration = const PictureInPictureConfiguration (),
8926 });
@@ -112,47 +49,18 @@ class StreamCallContainer extends StatefulWidget {
11249 /// The action to perform when the call is disconnected. By default, it pops the current route.
11350 final void Function (CallDisconnectedProperties )? onCallDisconnected;
11451
115- /// Builder used to create a custom incoming call widget.
116- ///
117- /// If [incomingCallBuilder] is provided, the whole [StreamCallContainer] widget will
118- /// rebuild on every call state change.
119- /// Recommend to use [incomingCallWidgetBuilder] which is not rebuild on every state change.
120- @Deprecated ('Use [incomingCallWidgetBuilder] instead.' )
121- final IncomingCallBuilder ? incomingCallBuilder;
122-
12352 /// Builder used to create a custom incoming call widget.
12453 final CallWidgetBuilder ? incomingCallWidgetBuilder;
12554
126- /// Builder used to create a custom outgoing call widget.
127- ///
128- /// If [outgoingCallBuilder] is provided, the whole [StreamCallContainer] widget will
129- /// rebuild on every call state change.
130- /// Recommend to use [outgoingCallWidgetBuilder] which is not rebuild on every state change.
131- @Deprecated ('Use [outgoingCallWidgetBuilder] instead.' )
132- final OutgoingCallBuilder ? outgoingCallBuilder;
133-
13455 /// Builder used to create a custom outgoing call widget.
13556 final CallWidgetBuilder ? outgoingCallWidgetBuilder;
13657
137- /// Builder used to create a custom call content widget.
138- ///
139- /// If [callContentBuilder] is provided, the whole [StreamCallContainer] widget will
140- /// rebuild on every call state change.
141- /// Recommend to use [callContentWidgetBuilder] which is not rebuild on every state change.
142- @Deprecated ('Use [callContentWidgetBuilder] instead.' )
143- final CallContentBuilder ? callContentBuilder;
144-
14558 /// Builder used to create a custom call content widget.
14659 final CallWidgetBuilder ? callContentWidgetBuilder;
14760
14861 /// Configuration for picture-in-picture mode.
14962 final PictureInPictureConfiguration pictureInPictureConfiguration;
15063
151- bool get _shouldListenToCallState =>
152- incomingCallBuilder != null ||
153- outgoingCallBuilder != null ||
154- callContentBuilder != null ;
155-
15664 @override
15765 State <StreamCallContainer > createState () => _StreamCallContainerState ();
15866}
@@ -165,16 +73,12 @@ class _StreamCallContainerState extends State<StreamCallContainer> {
16573 /// Represents a call.
16674 Call get call => widget.call;
16775
168- /// Holds all information about the call.
169- CallState ? _callState;
170-
17176 /// Holds only status information about the call.
17277 late CallStatus _callStatus;
17378
17479 @override
17580 void initState () {
17681 super .initState ();
177- _listenToCallStateIfNeeded ();
17882 _listenToCallStatus ();
17983 _connect ();
18084 }
@@ -188,7 +92,6 @@ class _StreamCallContainerState extends State<StreamCallContainer> {
18892 _callStatusSubscription? .cancel ();
18993 _callStatusSubscription = null ;
19094
191- _listenToCallStateIfNeeded ();
19295 _listenToCallStatus ();
19396 }
19497 }
@@ -202,29 +105,13 @@ class _StreamCallContainerState extends State<StreamCallContainer> {
202105 super .dispose ();
203106 }
204107
205- void _listenToCallStateIfNeeded () {
206- if (widget._shouldListenToCallState) {
207- _callState = call.state.value;
208- _callStateSubscription = call.state.listen (_setState);
209- } else {
210- _callState = null ;
211- }
212- }
213-
214108 void _listenToCallStatus () {
215109 _callStatus = call.state.value.status;
216110 _callStatusSubscription = call
217111 .partialState ((state) => state.status)
218112 .listen (_setStatus);
219113 }
220114
221- void _setState (CallState callState) {
222- _logger.v (() => '[setState] callState.status: ${callState .status }' );
223- setState (() {
224- _callState = callState;
225- });
226- }
227-
228115 void _setStatus (CallStatus callStatus) {
229116 _logger.v (() => '[setStatus] callState.status: $callStatus ' );
230117 setState (() {
@@ -286,46 +173,26 @@ class _StreamCallContainerState extends State<StreamCallContainer> {
286173 }
287174
288175 Widget _buildIncomingCall () {
289- assert (
290- _callState != null || widget.incomingCallBuilder == null ,
291- 'Call state is supposed to be available to build the incoming call widget.' ,
292- );
293-
294176 return widget.incomingCallWidgetBuilder? .call (context, call) ??
295- widget.incomingCallBuilder? .call (context, call, _callState! ) ??
296177 StreamIncomingCallContent (
297178 call: call,
298- callState: _callState,
299179 onAcceptCallTap: widget.onAcceptCallTap,
300180 onDeclineCallTap: widget.onDeclineCallTap,
301181 );
302182 }
303183
304184 Widget _buildOutgoingCall () {
305- assert (
306- _callState != null || widget.outgoingCallBuilder == null ,
307- 'Call state is supposed to be available to build the outgoing call widget.' ,
308- );
309185 return widget.outgoingCallWidgetBuilder? .call (context, call) ??
310- widget.outgoingCallBuilder? .call (context, call, _callState! ) ??
311186 StreamOutgoingCallContent (
312187 call: call,
313- callState: _callState,
314188 onCancelCallTap: widget.onCancelCallTap,
315189 );
316190 }
317191
318192 Widget _buildCallContent () {
319- assert (
320- _callState != null || widget.callContentBuilder == null ,
321- 'Call state is supposed to be available to build the call content widget.' ,
322- );
323-
324193 return widget.callContentWidgetBuilder? .call (context, call) ??
325- widget.callContentBuilder? .call (context, call, _callState! ) ??
326194 StreamCallContent (
327195 call: call,
328- callState: _callState,
329196 onBackPressed: widget.onBackPressed,
330197 onLeaveCallTap: widget.onLeaveCallTap,
331198 pictureInPictureConfiguration: widget.pictureInPictureConfiguration,
0 commit comments