Skip to main content
Beta The Cello Flutter SDK allows you to use Cello for iOS and Cello for Android in your Flutter apps. With a plug-n-play mobile component, your users can easily share their invite link with their friends and network using mobile sharing options convenient for them, receive rewards and get paid out.

Installation

A basic installation takes around 15 minutes, but will take a little longer if you want to customize the way the Cello Referral Component is launched. Compatibility
  • The Cello Flutter SDK supports Flutter 3.3.0 and above (Dart 3+).
  • Cello for iOS supports iOS 15+.
  • Cello for Android supports API 21+.

Install Cello

Or add to your pubspec.yaml:
Then run:

Android Setup

The Flutter plugin automatically handles linking for Android. Ensure your app’s android/app/build.gradle has the correct configuration:
Ensure your project’s android/build.gradle (or app-level) includes:

Internet Permission

Add internet permission in android/app/src/main/AndroidManifest.xml:

iOS Setup

The Flutter plugin automatically handles linking for iOS via CocoaPods. From your ios/ directory, run:
Ensure your ios/Podfile specifies iOS 15.0+:

Choose an Environment

In your Cello SDK setup, you have the flexibility to select the environment in which your application will run. This feature is especially useful for different stages of development, such as testing in a development or staging environment before going live in production. The available environments are:
  • production or prod (Production) (default)
  • sandbox (Sandbox)
You specify the environment when initializing Cello:

Customize the Cello Referral Component

The Cello Flutter SDK allows for various levels of customization to better fit into your app’s design and flow. One of the main components you might want to customize is the Referral component

Choose Your Launcher

The library provides two ways to launch the Referral component: Default launcher If you choose to go with the default launcher, you can call the showFab() method from the Cello library to present a Floating Action Button (FAB) within your app. This FAB is pre-styled but may not perfectly match your app’s look and feel.
Custom launcher If the default launcher does not fit your needs, you can implement your own custom launcher. This could be any UI element like a button, menu item, or even a gesture. To open the Referral component using a custom launcher, you can call Cello.openWidget().

Flutter API

Cello.initialize(CelloInitializeOptions): Future<CelloConfiguration>

Initializes the Cello referral component.

CelloInitializeOptions

ProductUserDetails

Optional object with user information:

Cello.showFab(): Future<void>

Shows the default Cello button that launches the Referral Component

Cello.hideFab(): Future<void>

Hides the default Cello button that launches the Referral Component

Cello.openWidget(): Future<void>

Opens the referral component.

Cello.hideWidget(): Future<void>

Hides the referral component.

Cello.getActiveUcc(): Future<Map<String, String>>

A method to get an active ucc and related data for the currently logged in user.

Cello.getCampaignConfig(): Future<Map<String, dynamic>>

A method to get the campaign configuration.

Cello.changeLanguage(String language): Future<void>

A method to change the language of the Referral component at runtime without re-initialising it. Note: Requires iOS 14+ on iOS platform.

Cello.setThemeMode(String themeMode): Future<void>

A method to change the theme mode of the Referral component at runtime without re-initialising it. Note: Requires iOS 14+ on iOS platform.
Parameters:
  • themeMode (String): The theme mode to set. Valid values are "light", "dark", or "system".

Cello.updateToken(String token): Future<void>

Updates the user authentication token without re-initializing. Note: Requires iOS 14+ on iOS platform.

Cello.shutdown(): Future<void>

Shuts down connection to Cello and unmounts the component

Cello.tokenEvents: Stream<CelloTokenEvent>

A broadcast stream that emits token lifecycle events.

Error Handling

Exception types

The Cello Flutter SDK throws PlatformException with specific error codes when operations fail:
Tip: Catch PlatformException and inspect error.code, error.message, and error.details for extra context.

Common error scenarios

1. Initialization exception

Symptoms: InitializationError or InitializationException in the catch block. Fix: Validate credentials, confirm network connectivity, and ensure you selected the right environment (production vs sandbox). Check native logs for additional details.

2. Methods called before initialization

Symptoms: ClientUnavailable error on Android or native console warnings. Fix: Ensure Cello.initialize completes successfully before calling other methods like showFab() or openWidget(). Track initialization state in your app.

3. Platform feature limitations

Cello.changeLanguage, Cello.setThemeMode, and Cello.updateToken require iOS 14+ on iOS. On older devices these methods reject with Unavailable error. Guard these calls with a platform/version check if needed.

Error handling best practices

1. Wrap initialization in try/catch:
2. Delay UI interactions: Only call Cello.showFab() or Cello.openWidget() after a successful initialization. Keep a dedicated isCelloReady state flag in your widgets.
3. Handle token lifecycle: Listen to Cello.tokenEvents and refresh tokens proactively before they expire:
4. Retry on transient errors: For recoverable failures (network timeouts, InitializationError), schedule a retry with exponential backoff. Limit retries to avoid looping endlessly. 5. Log error details: Capture error codes, messages, and relevant details in your logging/monitoring solution to help support diagnose issues quickly.