directory
pageON THIS PAGE

Add custom components

Customize the foreground of view

If you want to add some custom components at the top level of view, such as, you want to display advertisements, etc., then you can use foreground in ZegoUIKitPrebuiltCallConfig. This callback, similar to other Flutter’s Builder callbacks, requires you (the developer) to return a custom Widget that will be placed at the top of the view.

​The position of the Widget can be specified by using the Flutter Positioned.

Here shows [How to add a advertisement]:

Copy
Copy

The effect will be like this:

null

Customize the background of view

If you need to customize the view in audio mode, for example, setting the background image, you can use background in audioVideoViewConfig. This callback, similar to other Flutter’s Builder callbacks, requires you (the developer) to return a custom Widget that will be placed in the view in audio mode.

​This config is only valid when the user turns off the camera (because the video view will be displayed automatically when the camera is on). The position of the Widget can be specified by using the Flutter Positioned.

Here shows [How to add a background]:

Copy
Copy

The effect will be like this:

null

Customize the foreground of user's view

If you want to add some custom components at the top level of the user's view, such as, you want to display the user avatars when the video view is displayed, add user-level icons, etc., then you can use foregroundBuilder in audioVideoViewConfig. This callback, similar to other Flutter’s Builder callbacks, requires you (the developer) to return a custom Widget that will be placed at the top of the view.

​The position of the Widget can be specified by using the Flutter Positioned.

Here shows [How to add a user avatar to the lower left corner during a video call]:

Copy
Copy

The effect is as follows:

When the camera is on

When the camera is off

null
null

As you can see, the custom component is displayed at the top regardless of whether the camera is on or off. If you want to display custom widgets only when the camera is on, you'll need to build different views depending on the user's camera status. As it happens, the Call Kit provides an out-of-box ValueNotifier, including the CameraStateNotifier which can be used to monitor the user's camera status.

Try to customize the reference code with Flutter's ValueListenableBuilder:

Copy
Copy

The effect after modification is as follows:

When the camera is on

When the camera is off

null
null

Customize the background of user's view

If you need to customize the user's view in audio mode, for example, setting the background image, you can use backgroundBuilder in audioVideoViewConfig. This callback, similar to other Flutter’s Builder callbacks, requires you (the developer) to return a custom Widget that will be placed in the view in audio mode.

​This config is only valid when the user turns off the camera (because the video view will be displayed automatically when the camera is on). The position of the Widget can be specified by using the Flutter Positioned.

Here shows [How to use a Gaussian Blur user image as the background image in audio mode]:

Copy
Copy

The effect will be like this:

null
pageON THIS PAGE
backBack to top