Integrate SDKs in Hybrid Flutter and native Apps

We support the integration of SDK components in hybrid Flutter and native applications. You can utilize Flutter widgets on Flutter pages and native components on native pages. SDK global handlers and callbacks are implemented on the native side, so your existing native integration code continues to drive shopping behavior, analytics, and other global events across both Flutter and native pages.

This guide is written for the common case: you have an existing native app with the Firework iOS/Android SDK integrated, and you are adding Flutter pages to it. With this approach, all your existing native SDK integration code (handlers, callbacks, shopping configurations, analytics listeners, etc.) keeps working as-is — you only need to add the Flutter SDK on top.

Initialization

Install SDKs

Since the Flutter SDK depends on the native SDKs, installing the Flutter SDK will automatically install the native SDKs as well. Please use the following code to install the Flutter SDK, after which the native SDKs will also be installed.

flutter pub add fw_flutter_sdk

iOS

Run pod install in the root directory of the iOS project. If you encounter the error CocoaPods could not find compatible versions for pod "FireworkVideo", run pod update FireworkVideo instead.

Configure and initialize native SDKs

Follow the native SDK guides below to configure and initialize the SDK on each platform. The native SDKs are already installed via the Flutter SDK in the previous step, so you can skip the installation sections in these guides.

Call markInitCalled in Dart side

As shown in the following code snippets, we need to invoke markInitCalled with directlyCallNativeInit set to true on the Dart side.

FireworkSDK.getInstance().markInitCalled(directlyCallNativeInit: true);

Use Flutter widgets

You can utilize Flutter widgets on the Flutter page. Please consult the following docs for further details:

Use native components

You can utilize native components on the native page. Please consult the following docs for further details:

Analytics

Receive analytics events on the native side. Please consult the following docs for further details:

Shopping

Customize shopping configurations and click behaviors on the native side. Please consult the following docs for further details:

Live Stream Support

To enable support for livestream, please consult the following docs:

Last updated

Was this helpful?