This article provides general instructions and precautions when you upgrade the Express Flutter SDK version to 2.23.0 or above.
To support developers in implementing the video rendering feature, the ZegoExpressTextureRenderUtils and ZegoExpressPlatformViewUtils API modules have been removed since v2.23.0.
When upgrading from an old version to v2.23.0, developers need to migrate to the new ZegoExpressCanvasViewUtils API module to implement the video rendering feature.
The new ZegoExpressCanvasViewUtils API module supports both External Texture and PlatformView rendering methods.
The Express Flutter SDK supports two rendering methods: External Texture and PlatformView
Prior to v2.22.0, the two rendering methods correspond to two sets of APIs. Since Flutter only supports one of the rendering methods on some platforms, developers need to determine which set of APIs can be used in the corresponding platform.
ZegoExpressTextureRenderUtils
ZegoExpressPlatformViewUtils
To reduce the cost of use for developers, a new set of APIs is launched in the v2.22.0 version:
This set of APIs eliminates the differences associated with the use of the previous two rendering methods and supports both External Texture and PlatformView rendering methods.
For platforms that support both rendering methods, the use of PlatformView or External Texture is determined according to the enablePlatformView parameter when createEngineWithProfile is called.
For platforms that only support one of the rendering methods, the supported rendering method is used by default, and the enablePlatformView parameter will be ignored. The behavior mode of the enablePlatformView parameter is preference instead of specify.
The SDK v2.23.0 or above supports macOS and Windows. The following rendering methods and platforms are supported by the current version:
| Method\Platform | Android | iOS | macOS | Windows | Web | Linux |
|---|---|---|---|---|---|---|
| External Texture | ✔️ | ✔️ | ✔️ | ✔️ | ✖ | ✖ |
| PlatformView | ✔️ | ✔️ | ✖ | ✖ | ✔️ | ✖ |
To support CanvasView, the implementation of the video rendering function is refactored. While this improves performance, it also destroys the original ZegoExpressTextureRenderUtils behavior (view mode abnormal).
To ensure a good user experience, we decided to delete the ZegoExpressTextureRenderUtils and ZegoExpressPlatformViewUtils API modules.
Developers should migrate to the new ZegoExpressCanvasViewUtils API module, and take note of the following API changes:
| Old | New |
|---|---|
createTextureRenderer |
createCanvasView |
destroyTextureRenderer |
destroyCanvasView |
updateTextureRendererSize |
No need to call it anymore, the SDK will handle it automatically. |
createPlatformView |
createCanvasView |
destroyPlatformView |
destroyCanvasView |
You can refer to the following sample code or example demo for migration.
// TextureRenderer
late int _viewID;
Widget? _viewWidget;
void start() {
ZegoExpressEngine.instance.createTextureRenderer(width, height).then((viewID) {
_viewID = viewID;
setState(() {
_viewWidget = Texture(textureId: viewID)
});
ZegoCanvas canvas = ZegoCanvas.view(viewID);
// Call [startPreview] or [startPlayingStream]
// ......
});
}
void stop() {
// Call [stopPreview] or [stopPlayingStream]
// ......
ZegoExpressEngine.instance.destroyTextureRenderer(_viewID);
}
// PlatformView
late int _viewID;
Widget? _viewWidget;
void start() {
setState(() {
_viewWidget = ZegoExpressEngine.instance.createPlatformView((viewID) {
_viewID = viewID;
ZegoCanvas canvas = ZegoCanvas.view(viewID);
// Call [startPreview] or [startPlayingStream]
// ......
});
});
}
void stop() {
// Call [stopPreview] or [stopPlayingStream]
// ......
ZegoExpressEngine.instance.destroyPlatformView(_viewID);
}
// CanvasView
late int _viewID;
Widget? _viewWidget;
void start() {
ZegoExpressEngine.instance.createCanvasView((viewID) {
_viewID = viewID;
// Call [startPreview] or [startPlayingStream]
// ......
}).then((widget) {
setState(() {
_viewWidget = widget;
});
});
}
void stop() {
// Call [stopPreview] or [stopPlayingStream]
// ......
ZegoExpressEngine.instance.destroyCanvasView(_viewID);
}
