Flutter Integration

Current Flutter Persona guide covering initializeApiKey, the Onairos widget, deep links, and the wrapper callback shape.

Updated 19 March 2026
fluttermobileiosandroidpersona

Flutter Integration

Use the onairos Flutter package when you want the current wrapper flow in a Flutter app.

Use these Flutter names

The current high-level Flutter wrapper uses initializeApiKey(...), the Onairos widget, and onResolved(apiUrl, token, userData). Do not copy the React Native onComplete examples into Flutter.

1. Install the package

dart pub add onairos

2. Initialize the SDK

import 'package:onairos/initialize_api_key.dart';

await initializeApiKey(
  apiKey: 'your_api_key',
  environment: 'production',
);

Set up your app's URL scheme on iOS and Android, then pass the scheme string into returnLink. If your callback is yourapp://callback, pass yourapp as the returnLink value.

4. Render the high-level widget

import 'package:flutter/material.dart';
import 'package:onairos/initialize_api_key.dart';
import 'package:onairos/onairos.dart';

class OnairosDemo extends StatefulWidget {
  const OnairosDemo({super.key});

  @override
  State<OnairosDemo> createState() => _OnairosDemoState();
}

class _OnairosDemoState extends State<OnairosDemo> {
  @override
  void initState() {
    super.initState();
    initializeApiKey(apiKey: 'your_api_key');
  }

  @override
  Widget build(BuildContext context) {
    return Onairos(
      AppName: 'YourApp',
      returnLink: 'yourapp',
      googleClientId: 'your-google-client-id.apps.googleusercontent.com',
      requestData: {
        'basic': {
          'name': 'Basic Profile',
          'description': 'Required account basics',
          'reward': 'Required'
        },
        'preferences': {
          'name': 'Preferences',
          'description': 'Use inferred tastes in your app',
          'reward': 'Better recommendations'
        },
        'personality': {
          'name': 'Personality',
          'description': 'Use traits and summaries in your app',
          'reward': 'Deeper personalization'
        }
      },
      onResolved: (apiUrl, token, userData) {
        print(apiUrl);
        print(token);
        print(userData['apiResponse']);
      },
    );
  }
}

Main wrapper inputs

PropRequiredWhat it does
AppNameYesThe app name shown inside the Flutter wrapper flow.
returnLinkYesYour app's URL scheme. The wrapper expects the callback to come back through that scheme.
requestDataNoMap-shaped consent copy shown in the flow. The current consent screen centers on basic, preferences, and personality.
onResolvedNoCalled as onResolved(apiUrl, token, userData) when the flow finishes.
googleClientIdNoProvide this when you need YouTube / Google sign-in inside the Flutter flow.
Flutter wrapper note

The current Flutter package still exposes some legacy naming. Older examples may show personality_traits, sentiment_analysis, or auto; the current docs path uses the built-in consent ids basic, preferences, and personality.

Connector customization

  • The current high-level Flutter wrapper does not expose a public allowedPlatforms or recommendedPlatforms API like React Native.
  • The wrapper currently ships with its own built-in connector set and ordering.
  • preferredPlatform is threaded into the modal flow, but it is not applied inside the current NpmUniversalOnboarding screen. Do not rely on it to reorder the connector UI.

What the callback gives you

The Flutter wrapper completes through onResolved(apiUrl, token, userData). The main values are:

ArgumentMeaning
apiUrlThe returned API URL for the approved request
tokenShort-lived token for that returned API URL
userDataUser/session details plus any merged flow data the wrapper collected, including fetched response fields when the internal data request completes

Manual fetch example

final response = await http.post(
  Uri.parse(apiUrl),
  headers: {
    'Authorization': 'Bearer $token',
    'Content-Type': 'application/json',
  },
  body: jsonEncode({
    'Input': {
      'item1': {'text': 'Example content', 'category': 'general'}
    }
  }),
);
Next step

Use Inference API if you want to call the returned route yourself after the Flutter flow completes.