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
pubspec.yaml:
Android Setup
The Flutter plugin automatically handles linking for Android. Ensure your app’sandroid/app/build.gradle has the correct configuration:
android/build.gradle (or app-level) includes:
Internet Permission
Add internet permission inandroid/app/src/main/AndroidManifest.xml:
iOS Setup
The Flutter plugin automatically handles linking for iOS via CocoaPods. From yourios/ directory, run:
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:productionorprod(Production) (default)sandbox(Sandbox)
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 componentChoose 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 theshowFab() 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.
Cello.openWidget().
Flutter API
Cello.initialize(CelloInitializeOptions): Future<CelloConfiguration>
Initializes the Cello referral component.
CelloInitializeOptions
| Property | Type | Required | Description |
|---|---|---|---|
| productId | String | yes | Your product ID from Cello Portal |
| token | String | yes | User authentication token |
| environment | String? | no | Environment: "production" or "sandbox" |
| productUserDetails | ProductUserDetails | no | User details object (see below) |
| language | String? | no | Initial language of the widget |
| themeMode | String? | no | Initial theme mode: "light", "dark", or "system" |
ProductUserDetails
Optional object with user information:| Property | Type | Description |
|---|---|---|
| firstName | String | User’s first name |
| lastName | String | User’s last name |
| fullName | String | User’s full name |
| String | User’s email address |
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.
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 throwsPlatformException with specific error codes when operations fail:
| Code | Platform(s) | Trigger | Typical causes |
|---|---|---|---|
InitializationError | iOS & Android | Cello.initialize completes with native failure | Invalid/empty product ID or token, network issues, bad environment |
InitializationException | Android | Unexpected exception inside Cello.initialize | Activity finishing, SDK not linked correctly, runtime crash |
ActivityUnavailable | Android | Cello.initialize without an active Activity | Initialization triggered too early (e.g. before app fully ready) |
TokenUpdateError | iOS | Cello.updateToken failure | Token expired/invalid, network errors |
LanguageChangeError | iOS | Cello.changeLanguage failure | Unsupported language code, network errors |
ThemeModeChangeError | iOS | Cello.setThemeMode failure | Invalid theme mode value, network errors |
Unavailable | iOS | Feature requires iOS 14+ | Device running < iOS 14 when calling token, language, or theme updates |
ClientUnavailable | Android | Method called before initialization | SDK not initialized before calling other methods |
CelloError | Android | Generic SDK error | Various SDK-level errors |
UccError | Android | Cello.getActiveUcc threw | SDK not initialized, network or serialization errors |
CampaignConfigError | Android | Cello.getCampaignConfig threw | SDK not initialized, configuration not ready |
InvalidArguments | iOS & Android | Missing or invalid method arguments | Required parameters not provided or have invalid values |
Tip: CatchPlatformExceptionand inspecterror.code,error.message, anderror.detailsfor 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:Cello.showFab() or Cello.openWidget() after a successful initialization. Keep a dedicated isCelloReady state flag in your widgets.
Cello.tokenEvents and refresh tokens proactively before they expire:
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.