Integrate with Flutter
Experimental Flutter integration guide, proceed with caution
Overview
Monterosa / Interaction SDK allows for the creation of native components that can be integrated into Flutter applications using platform views. This document outlines the integration process for both Android and iOS platforms.
Platform Views
Flutter provides two key mechanisms for embedding native views:
Android:
AndroidViewis used to host native Android componentsiOS:
UiKitViewis used to embed native iOS views
Integration Steps
1. Prerequisite
This guide assumes you have setup and initialised an instance of the Monterosa / Interaction SDK. Refer to the Get the SDK section if you haven't done so yet or require more information.
2. Create Native Views and View Factories
import Flutter
import MonterosaSDKLauncherKit
import UIKit
class NativeViewFactory: NSObject, FlutterPlatformViewFactory {
private var messenger: FlutterBinaryMessenger
init(messenger: FlutterBinaryMessenger) {
self.messenger = messenger
super.init()
}
func create(withFrame frame: CGRect, viewIdentifier viewId: Int64, arguments args: Any?) -> any FlutterPlatformView {
return NativeUIView(frame: frame, viewIdentifier: viewId, arguments: args, binaryMessenger: messenger)
}
}
class NativeUIView: NSObject, FlutterPlatformView {
private var experience: ExperienceView
init(
frame: CGRect,
viewIdentifier viewId: Int64,
arguments args: Any?,
binaryMessenger messenger: FlutterBinaryMessenger?
) {
experience = Launcher.getExperience()
super.init()
}
func view() -> UIView {
return experience
}
}3. Register Native View Factories
4. Embed Native Views in Flutter
Create a Flutter widget that uses the appropriate platform view based on the current platform:
You can now use NativeSDKView in your Flutter application to embed the native SDK component.
Advanced Configuration
The platform views can be further customized with creation parameters, layout preferences, and gesture recognizers:
Resources
Troubleshooting
If you encounter issues with the native view integration:
Ensure you're using the latest version of the Monterosa SDK and it's properly setup.
Check platform-specific logs for error messages.
Verify that the view type identifiers match between Flutter and native code
Consult the platform-specific documentation for additional configuration requirements
Last updated

