returningai_widget 0.1.2 copy "returningai_widget: ^0.1.2" to clipboard
returningai_widget: ^0.1.2 copied to clipboard

Official Flutter SDK for embedding ReturningAI widgets on Android and iOS.

returningai_widget #

pub

Embed ReturningAI custom product widgets in Flutter apps on Android and iOS.

The SDK authenticates in Dart and gives the WebView only a short-lived access token. Hosts custom rai-custom-widget bundle and page content.

Install #

dependencies:
  returningai_widget: ^0.1.2

Requirements:

  • Flutter 3.38+
  • Dart 3.10+
  • Android API 24+
  • iOS 13+

Android apps must declare internet permission:

<uses-permission android:name="android.permission.INTERNET" />

Usage #

final controller = ReturningAIWidgetController();

ReturningAIWidget(
  controller: controller,
  configuration: ReturningAIWidgetConfiguration.customBundle(
    widgetId: 'YOUR_WIDGET_ID',
    bundleUrl: Uri.parse(
      'https://widgets.example/custom-widget/bundle/store/widget.js',
    ),
    clientOrigin: Uri.parse('https://mobile-client.example'),
  ),
  embedTokenProvider: () async => hostMintedEmbedToken,
  onEvent: onEvent,
  onError: onError,
  onExternalNavigation: onExternalNavigation,
);

clientOrigin must be the exact HTTPS origin allowlisted for the widget in ReturningAI. It is not a Flutter route or app URL.

Mint embed tokens on your backend. Do not put accessId, accessKey, or embed tokens in the app, HTML, bridge, or WebView URLs.

Pin runtimeUrl in production. The default is unpkg @returningai/widget-sdk latest.

Controller #

await controller.reload();
await controller.retry();
await controller.updateTheme(ReturningAIWidgetTheme.dark);
await controller.logout();
await controller.invalidate();

On ReturningAIWidgetSessionExpired, return a freshly minted embed token from embedTokenProvider. Call invalidate() when the host user signs out.

0
likes
120
points
125
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Official Flutter SDK for embedding ReturningAI widgets on Android and iOS.

Repository (GitHub)
View/report issues

Topics

#returningai #widget #webview

License

unknown (license)

Dependencies

flutter, http, webview_flutter, webview_flutter_android, webview_flutter_wkwebview

More

Packages that depend on returningai_widget