iNuba App logo

iNuba App SDK


iNuba app integration as SDK for Flutter mobile applications

Website   •   Download app   •   Contact us

The iNuba App SDK for Flutter allows you to integrate iNuba services seamlessly into your Flutter application with type-safe configuration and bidirectional communication.

The package uses the flutter_inappwebview plugin to provide a robust WebView experience with bidirectional communication between Flutter and JavaScript.

To obtain your iNuba SDK access credentials, please contact the iNuba development team.

Installation

Add the iNuba Flutter SDK to your project by including it in your pubspec.yaml file:

dependencies:
  inuba_flutter_sdk: ^1.4.1

Then run:

flutter pub get

Quick Start

Basic Usage

Import the package in your project:

import 'package:inuba_flutter_sdk/inuba_flutter_sdk.dart';

Basic Configuration

Basic configuration with required parameters:

INubaSDK(
  clientToken: 'your_client_token',
  userToken: 'your_user_token',
)

Advanced Configuration

Full configuration with all available options:

// Create controller for advanced SDK interactions
final controller = INubaSDKController();

INubaSDK(
  clientToken: 'your_client_token',
  userToken: 'your_user_token',

  // Optional: Controller for SDK interactions
  controller: controller,

  // Optional: Initial deeplink navigation
  initialDeeplink: DeepLink.showHome,

  // Optional white label
  whitelabel: Whitelabel.iNuba,

  // Optional environment
  environment: Environment.production,

  // Optional platform identification
  platform: Platform.android,

  // Optional display mode
  displayMode: DisplayMode.fullScreen,

  // Optional language
  language: Language.en,

  // Optional unit measurement
  unitMeasurement: UnitMeasurement.metric,

  // Required: Handle file downloads from WebView (Highly recommended to implement)
  onDownload: (url, filename, downloadAndShare) {
    // Handle file download from WebView
    // Use flutter_downloader, flutter_file_downloader packages or your own implementation
  },

  // Optional: Handle SDK close events (It only works if displayMode is DisplayMode.fullScreen)
  onClose: (reason) {
    // Custom close behavior (defaults to Navigator.pop)
    // Use your own navigation system
  },
)

Configuration Options

Whitelabel

  • Whitelabel.iNuba: Default iNuba branding (default)
  • Whitelabel.custom('YourBrand'): Custom branding (Contact iNuba to get your own branding)

Environment

  • Environment.develop: Development environment (default)
  • Environment.production: Production environment

Platform

  • Platform.android: Android platform
  • Platform.ios: iOS platform

Display Mode

  • DisplayMode.fullScreen: Full screen presentation (default)
  • DisplayMode.inlineView: Inline view presentation

Language

  • Language.userChoice: Let the user choose their preferred language in the app (default)
  • Language.en: English language
  • Language.es: Spanish language

Unit Measurement

  • UnitMeasurement.userChoice: Let the user choose their preferred unit system in the app (default)
  • UnitMeasurement.metric: Metric system (kg, cm)
  • UnitMeasurement.imperial: Imperial system (lb, in)
  • DeepLink.showHome: Navigate to home screen (default)
  • DeepLink.fromNotification(payload'deeplink'): Create a deeplink from a notification payload
  • DeepLink.showMindScreen: Navigate to mind/mental health screen
  • DeepLink.showNutritionScreen: Navigate to nutrition screen
  • DeepLink.showFitnessScreen: Navigate to fitness screen
  • And more... see DeepLink for all available deeplinks

Event Callbacks

Download Event

Handle file downloads initiated from the WebView:

onDownload: (String url, String filename, bool downloadAndShare) {
  // url: File URL to download
  // filename: Suggested filename
  // downloadAndShare: Whether to share after download

  // Implement your download logic here
}

Close Event

Handle SDK close requests from the WebView:

onClose: (CloseReason reason) {
  // reason: Close reason from WebView (default: 'unknown')
  // Implement your close logic here
}

Note: If onClose is not provided, the SDK automatically calls Navigator.pop(context, reason).

SDK Controller

The INubaSDKController allows you to interact with the SDK programmatically, enabling dynamic navigation and control.

Creating a Controller

final controller = INubaSDKController();

INubaSDK(
  controller: controller,
  // ... other parameters
)

Controller Actions

Navigate to different screens dynamically:

// Navigate to specific screens
controller.injectDeeplink(DeepLink.showHome);
controller.injectDeeplink(DeepLink.fromNotification(payload['deeplink']));
controller.injectDeeplink(DeepLink.showMindScreen);
controller.injectDeeplink(DeepLink.showNutritionScreen);
controller.injectDeeplink(DeepLink.showFitnessScreen);

// Wait for SDK to be ready before injecting
await controller.sdkReady.future;
controller.injectDeeplink(DeepLink.showCalendar);

Close SDK Programmatically

await controller.closeSDK();

Cache Management

The SDK automatically manages WebView cache and ensures users always see the latest version of the web interface. Version checking happens before loading the WebView, clearing cache only when necessary.

Manual Cache Clear (Optional)

For development purposes, you can manually clear the cache:

await INubaSDKController.clearCache();

Note: Manual cache clearing is rarely needed. The SDK automatically detects and updates when new versions are deployed. Not recommended for production environment.

Android Configuration

Add this provider configuration to your android/app/src/main/AndroidManifest.xml inside the <application> tag:

<provider
    android:name="com.pichillilorenzo.flutter_inappwebview_android.InAppWebViewFileProvider"
    android:authorities="${applicationId}.flutter_inappwebview_android.fileprovider"
    android:exported="false"
    android:grantUriPermissions="true">
    <meta-data
        android:name="android.support.FILE_PROVIDER_PATHS"
        android:resource="@xml/provider_paths"/>
</provider>

And add the internet permission outside the <application> tag:

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

Testing and Development

Physical Devices

It is highly recommended to test and run this SDK on physical devices rather than emulators. In our extensive testing, we have encountered multiple errors and issues on emulators that are completely resolved when using physical devices. Android and iOS emulators may exhibit WebView rendering problems, performance issues, and other unexpected behaviors that don't occur on real hardware.

Example Application

A complete example application is available in the example/ directory. To run it:

cd example
flutter run

See example/README.md for detailed integration instructions and best practices.

Support

For questions or issues, please contact the iNuba development team.

License

MIT License - see the LICENSE file for details.

Libraries

inuba_flutter_sdk
iNuba Flutter SDK