Incoming Call

The StreamCallContainer widget provides built-in support for displaying incoming calls. To handle incoming calls when your app is in the foreground, you can listen for the incoming call event and display the StreamCallContainer with the associated call.

import 'package:flutter/material.dart';
import 'package:stream_video_flutter/stream_video_flutter.dart';

// Example initState method in some top level widget
@override
void initState() {
  super.initState();

  final subscription = StreamVideo.instance.state.incomingCall.listen((call) {
        Navigator.push(
            context,
            MaterialPageRoute(builder: (context) => MyCallScreen(call)),
        );
    });
}

// remember to cancel the subscription when you no longer need it

class MyCallScreen extends StatelessWidget {
    const MyCallScreen(this.call, {super.key});

    final Call call;
    
    @override
    Widget build(BuildContext context) {
        return StreamCallContainer(
            call: call,
        );
    }
}

Preview of Incoming Call Screen

Customization

You can customize how the incoming call screen looks by providing your own widget:

StreamCallContainer(
    call: call,
    incomingCallBuilder: (context, call, callState) {
      return MyOwnIncomingCallScreen(call: call);
    },
)
© Getstream.io, Inc. All Rights Reserved.