# v2.23.0 Upgrade Guide

This article details the instructions and precautions for upgrading the Express Flutter SDK version to v2.23.0.

## Changes

In order to facilitate developers to implement the video rendering feature, the [ZegoExpressTextureRenderUtils\|_blank](https://pub.dev/documentation/zego_express_engine/2.22.0/zego_express_engine/ZegoExpressTextureRenderUtils.html) and [ZegoExpressPlatformViewUtils\|_blank](https://pub.dev/documentation/zego_express_engine/2.22.0/zego_express_engine/ZegoExpressPlatformViewUtils.html) API modules have been removed since v2.23.0.

Therefore, when upgrading from an old version to v2.23.0, developers need to migrate to the new [ZegoExpressCanvasViewUtils\|_blank](https://pub.dev/documentation/zego_express_engine/2.23.0/zego_express_engine/ZegoExpressCanvasViewUtils.html) API module to implement the video rendering feature.

The new [ZegoExpressCanvasViewUtils\|_blank](https://pub.dev/documentation/zego_express_engine/2.23.0/zego_express_engine/ZegoExpressCanvasViewUtils.html) API module can support both [External Texture\|_blank](https://api.flutter.dev/flutter/widgets/Texture-class.html) and [PlatformView\|_blank](https://docs.flutter.dev/development/platform-integration/android/platform-views) rendering methods.

## Reason

Express Flutter SDK supports two rendering methods: [External Texture\|_blank](https://api.flutter.dev/flutter/widgets/Texture-class.html) and [PlatformView\|_blank](https://docs.flutter.dev/development/platform-integration/android/platform-views)

Before 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 the corresponding platform can use.

- External Texture：[ZegoExpressTextureRenderUtils\|_blank](https://pub.dev/documentation/zego_express_engine/2.22.0/zego_express_engine/ZegoExpressTextureRenderUtils.html)
  - [createTextureRenderer\|_blank](https://pub.dev/documentation/zego_express_engine/2.22.0/zego_express_engine/ZegoExpressTextureRenderUtils/createTextureRenderer.html)
  - [destroyTextureRenderer\|_blank](https://pub.dev/documentation/zego_express_engine/2.22.0/zego_express_engine/ZegoExpressTextureRenderUtils/destroyTextureRenderer.html)
  - [updateTextureRendererSize\|_blank](https://pub.dev/documentation/zego_express_engine/2.22.0/zego_express_engine/ZegoExpressTextureRenderUtils/updateTextureRendererSize.html)
- PlatformView：[ZegoExpressPlatformViewUtils\|_blank](https://pub.dev/documentation/zego_express_engine/2.22.0/zego_express_engine/ZegoExpressPlatformViewUtils.html)
  - [createPlatformView\|_blank](https://pub.dev/documentation/zego_express_engine/2.22.0/zego_express_engine/ZegoExpressPlatformViewUtils/createPlatformView.html)
  - [destroyPlatformView\|_blank](https://pub.dev/documentation/zego_express_engine/2.22.0/zego_express_engine/ZegoExpressPlatformViewUtils/destroyPlatformView.html)

In order to reduce the cost of use for developers, a new set of API was launched in the v2.22.0 version:

- [ZegoExpressCanvasViewUtils\|_blank](https://pub.dev/documentation/zego_express_engine/2.23.0/zego_express_engine/ZegoExpressCanvasViewUtils.html)
  - [createCanvasView\|_blank](https://pub.dev/documentation/zego_express_engine/2.23.0/zego_express_engine/ZegoExpressCanvasViewUtils/createCanvasView.html)
  - [destroyCanvasView\|_blank](https://pub.dev/documentation/zego_express_engine/2.23.0/zego_express_engine/ZegoExpressCanvasViewUtils/destroyCanvasView.html)

This set of APIs removes the difference in the use of the previous two rendering methods, and can support both [External Texture\|_blank](https://api.flutter.dev/flutter/widgets/Texture-class.html) and [PlatformView\|_blank](https://docs.flutter.dev/development/platform-integration/android/platform-views) rendering methods.

- For platforms that support both rendering methods, whether to use [PlatformView\|_blank](https://docs.flutter.dev/development/platform-integration/android/platform-views) or [External Texture\|_blank](https://api.flutter.dev/flutter/widgets/Texture-class.html) will be determined according to the [enablePlatformView\|_blank](https://pub.dev/documentation/zego_express_engine/2.21.0/zego_express_engine/ZegoEngineProfile/enablePlatformView.html) parameter when calling [createEngineWithProfile\|_blank](https://pub.dev/documentation/zego_express_engine/latest/zego_express_engine/ZegoExpressEngine/createEngineWithProfile.html).

- For platforms that only support one of the rendering methods, the only supported rendering method will be used automatically, and the [enablePlatformView\|_blank](https://pub.dev/documentation/zego_express_engine/2.21.0/zego_express_engine/ZegoEngineProfile/enablePlatformView.html) parameter will be ignored, that is, the behavior mode of the [enablePlatformView\|_blank](https://pub.dev/documentation/zego_express_engine/2.21.0/zego_express_engine/ZegoEngineProfile/enablePlatformView.html) parameter is `preference` instead of `specify`.

The v2.23.0 SDK supports macOS and Windows. The rendering methods and platforms supported by the current version are as follows:

Methods\Platforms | Android | iOS | macOS | Windows | Web | Linux
------------------|---------|-----|-------|---------|-----|-------
External Texture  | ✔️       | ✔️   | ✔️     | ✔️       | ✖   | ✖
PlatformView      | ✔️       | ✔️   | ✖     | ✖       | ✔️   | ✖

In order to support `CanvasView`, we refactored the implementation of video rendering function, which improves the performance, but also destroys the original [ZegoExpressTextureRenderUtils](https://pub.dev/documentation/zego_express_engine/2.22.0/zego_express_engine/ZegoExpressTextureRenderUtils.html) behavior (view mode abnormal).

For user experience, we decided to delete the [ZegoExpressTextureRenderUtils\|_blank](https://pub.dev/documentation/zego_express_engine/2.22.0/zego_express_engine/ZegoExpressTextureRenderUtils.html) and [ZegoExpressPlatformViewUtils\|_blank](https://pub.dev/documentation/zego_express_engine/2.22.0/zego_express_engine/ZegoExpressPlatformViewUtils.html) API modules.

Developers need to migrate to the new [ZegoExpressCanvasViewUtils\|_blank](https://pub.dev/documentation/zego_express_engine/2.23.0/zego_express_engine/ZegoExpressCanvasViewUtils.html) API module, the specific API changes are as follows:

OLD | NEW
----|-----
[createTextureRenderer](https://pub.dev/documentation/zego_express_engine/2.22.0/zego_express_engine/ZegoExpressTextureRenderUtils/createTextureRenderer.html) | [createCanvasView](https://pub.dev/documentation/zego_express_engine/2.23.0/zego_express_engine/ZegoExpressCanvasViewUtils/createCanvasView.html)
[destroyTextureRenderer](https://pub.dev/documentation/zego_express_engine/2.22.0/zego_express_engine/ZegoExpressTextureRenderUtils/destroyTextureRenderer.html) | [destroyCanvasView](https://pub.dev/documentation/zego_express_engine/2.23.0/zego_express_engine/ZegoExpressCanvasViewUtils/destroyCanvasView.html)
[updateTextureRendererSize](https://pub.dev/documentation/zego_express_engine/2.22.0/zego_express_engine/ZegoExpressTextureRenderUtils/updateTextureRendererSize.html) | No need to call it anymore, the SDK will handle it automatically.
[createPlatformView](https://pub.dev/documentation/zego_express_engine/2.22.0/zego_express_engine/ZegoExpressPlatformViewUtils/createPlatformView.html) | [createCanvasView](https://pub.dev/documentation/zego_express_engine/2.23.0/zego_express_engine/ZegoExpressCanvasViewUtils/createCanvasView.html)
[destroyPlatformView](https://pub.dev/documentation/zego_express_engine/2.22.0/zego_express_engine/ZegoExpressPlatformViewUtils/destroyPlatformView.html) | [destroyCanvasView](https://pub.dev/documentation/zego_express_engine/2.23.0/zego_express_engine/ZegoExpressCanvasViewUtils/destroyCanvasView.html)

## Sample

You can refer to the following sample code or the [example demo\|_blank](https://github.com/zegoim/zego-express-flutter-sdk/tree/main/example) for migration.

### v2.22.0 and earlier

- External Texture

```dart
// 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);
    // Do something like calling [startPreview] or [startPlayingStream]
    // ......
  });
}

void stop() {
  // Do something like calling [stopPreview] or [stopPlayingStream]
  // ......
  ZegoExpressEngine.instance.destroyTextureRenderer(_viewID);
}
```

- PlatformView

```dart
// PlatformView

late int _viewID;
Widget? _viewWidget;

void start() {
  setState(() {
    _viewWidget = ZegoExpressEngine.instance.createPlatformView((viewID) {
      _viewID = viewID;
      ZegoCanvas canvas = ZegoCanvas.view(viewID);
      // Do something like calling [startPreview] or [startPlayingStream]
      // ......
    });
  });
}

void stop() {
  // Do something like calling [stopPreview] or [stopPlayingStream]
  // ......
  ZegoExpressEngine.instance.destroyPlatformView(_viewID);
}
```

### v2.23.0

```dart
// CanvasView

late int _viewID;
Widget? _viewWidget;

void start() {
  ZegoExpressEngine.instance.createCanvasView((viewID) {
    _viewID = viewID;
    // Do something like calling [startPreview] or [startPlayingStream]
    // ......
  }).then((widget) {
    setState(() {
      _viewWidget = widget;
    });
  });
}

void stop() {
  // Do something like calling [stopPreview] or [stopPlayingStream]
  // ......
  ZegoExpressEngine.instance.destroyCanvasView(_viewID);
}
```
