Skip to content

StreamCallContainer: BoxConstraints forces an infinite width when call is ended #1167

@Joji3110

Description

@Joji3110

Hi team,

I'm encountering an issue with StreamCallContainer in Flutter.

Steps to reproduce:

I wrap StreamCallContainer directly in a Scaffold:

class CustomCallScreen extends StatefulWidget {
  final Call call;
  final bool isVideo;
  final stream_chat.User? calleeUser;

  const CustomCallScreen({
    super.key,
    required this.call,
    required this.isVideo,
    required this.calleeUser,
  });

  @override
  _CustomCallScreenState createState() => _CustomCallScreenState();
}

class _CustomCallScreenState extends State<CustomCallScreen> {

  @override
  Widget build(BuildContext contex) {
    final customData = widget.call.state.value.custom;
    final isVideoCall = customData.values.firstOrNull.toString() == 'video';
    final callStatus = widget.call.state.value.status;

    debugPrint("🔍 CustomCallScreen Debug:");
    debugPrint("  - isVideoCall: $isVideoCall");
    debugPrint("  - callStatus: $callStatus");
    debugPrint(
      "  - callParticipants: ${widget.call.state.value.callParticipants.length}",
    );
    debugPrint("  - calleeUser: ${widget.calleeUser?.name ?? 'null'}");

    return Scaffold(
      body: StreamCallContainer(
        call: widget.call,
        // outgoingCallWidgetBuilder: (c,l) => StreamC
      ),
    );
  }
}

 Future<void> createRingingCall({required bool isVideoCall}) async {
    final client = StreamVideo.instance.state;
    debugPrint(
      '💡 Client isConnected BEFORE call: ${StreamVideo.isInitialized()}',
    );

    final call = StreamVideo.instance.makeCall(
      callType: StreamCallType.defaultType(),
      id: const Uuid().v4(),
      preferences: DefaultCallPreferences(dropIfAloneInRingingFlow: true),
    );

    debugPrint('💡 Creating call for user: ${calleeUser!.id}');
    final result = await call.getOrCreate(
      memberIds: [calleeUser!.id],
      video: isVideoCall,
      custom: {'isVideoCall': isVideoCall ? 'video' : 'audio'},
      ringing: true,
    );

    debugPrint('💡 getOrCreate returned: $result');

    result.fold(
      success: (success) async {
        debugPrint("Call created successfully: $call, result: $result");

        if (mounted) {
          Navigator.of(context).push(
            MaterialPageRoute(
              builder:
                  (_) => CustomCallScreen(
                    call: call,
                    isVideo: isVideoCall,
                    calleeUser: calleeUser,
                  ),
            ),
          );
        }
      },
      failure: (failure) {
        debugPrint('❌ Ошибка в создании звонка: ${failure.error.message}');
        ScaffoldMessenger.of(context).showSnackBar(
          SnackBar(
            backgroundColor: App.appTheme(context).primaryBlue,
            content: Text(
              failure.error.message,
              style: TextStyle(color: Colors.white),
            ),
          ),
        );
      },
    );
  }
}

Outgoing call widgets do not appear.

The active call widget is also not displayed.

If the call is ended by the other participant, I get the following exception.

Flutter version: 3.35.4
stream_video_flutter version: 1.2.3

It seems that the layout is generating unconstrained width for RenderConstrainedBox inside RenderPhysicalShape. I tried wrapping it in SizedBox / giving fixed height, but then the outgoing call UI disappears.

Could you advise the proper way to use StreamCallContainer so that outgoing call widgets display correctly without causing infinite constraints?

Full error message / stack trace:

======== Exception caught by rendering library =====================================================
The following assertion was thrown during performLayout():
BoxConstraints forces an infinite width.

These invalid constraints were provided to RenderPhysicalShape's layout() function by the following function, which probably computed the invalid constraints in question:
  RenderConstrainedBox.performLayout (package:flutter/src/rendering/proxy_box.dart:293:14)
The offending constraints were: BoxConstraints(w=Infinity, 46.0<=h<=Infinity)
The relevant error-causing widget was: 
  ElevatedButton ElevatedButton:file:///Users/zakapo3131/.pub-cache/hosted/pub.dev/stream_video_flutter-1.2.3/lib/src/call_controls/call_control_option.dart:59:12
...

======== Exception caught by rendering library =====================================================
The following assertion was thrown during performLayout():
RenderBox was not laid out: RenderConstrainedBox#e9232 relayoutBoundary=up6 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 2251 pos 12: 'hasSize'
...

This issue seems related to RenderConstrainedBox receiving unconstrained width when the call ends

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions